Skip to content

Commit afc7ef0

Browse files
committed
change i32 in package_parsers to uint
Signed-off-by: Luke-zhang-04 <[email protected]>
1 parent 5bb1e05 commit afc7ef0

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Diff for: CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8686
}
8787
```
8888

89-
3. in `src/onefetch/deps/package_parser.rs`, add a function whose name corresponds to your manager. This function should take in a `string` as the contents of the package manager file, and return `i32` as the number of dependencies
89+
3. in `src/onefetch/deps/package_parser.rs`, add a function whose name corresponds to your manager. This function should take in a `string` as the contents of the package manager file, and return `usize` as the number of dependencies
9090
```rust
91-
pub fn cargo(contents: &str) -> Result<i32> {
91+
pub fn cargo(contents: &str) -> Result<usize> {
9292
let parsed = contents.parse::<Value>()?;
9393

94-
Ok(parsed["dependencies"].as_table().unwrap().len() as i32)
94+
Ok(parsed["dependencies"].as_table().unwrap().len())
9595
}
9696
```
9797

Diff for: src/onefetch/deps/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use {
77
mod package_manager;
88
mod package_parser;
99

10-
type DependencyParser = fn(&str) -> Result<i32>;
10+
type DependencyParser = fn(&str) -> Result<usize>;
1111

1212
pub struct DependencyDetector {
1313
package_managers: HashMap<String, (DependencyParser, package_manager::PackageManager)>,

Diff for: src/onefetch/deps/package_parser.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
use crate::onefetch::error::*;
22
use {regex::Regex, toml::Value};
33

4-
pub fn cargo(contents: &str) -> Result<i32> {
4+
pub fn cargo(contents: &str) -> Result<usize> {
55
let parsed = contents.parse::<Value>()?;
66

7-
Ok(parsed["dependencies"].as_table().unwrap().len() as i32)
7+
Ok(parsed["dependencies"].as_table().unwrap().len())
88
}
99

10-
pub fn go_modules(contents: &str) -> Result<i32> {
10+
pub fn go_modules(contents: &str) -> Result<usize> {
1111
let count = Regex::new(r"v[0-9]+")?.find_iter(contents).count();
1212

13-
Ok(count as i32)
13+
Ok(count)
1414
}
1515

16-
pub fn npm(contents: &str) -> Result<i32> {
16+
pub fn npm(contents: &str) -> Result<usize> {
1717
let parsed = json::parse(contents)?;
1818

19-
Ok(parsed["dependencies"].len() as i32)
19+
Ok(parsed["dependencies"].len())
2020
}
2121

22-
pub fn pip(contents: &str) -> Result<i32> {
22+
pub fn pip(contents: &str) -> Result<usize> {
2323
let count = Regex::new(r"(^[A-z]+)|(\n[A-z]+)")?.find_iter(contents).count();
2424

25-
Ok(count as i32)
25+
Ok(count)
2626
}

0 commit comments

Comments
 (0)