Skip to content

Commit 0d6881c

Browse files
committed
Change extract_man to not return a Result (not needed).
1 parent 0e26eae commit 0d6881c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/bin/cargo/commands/help.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ fn try_help(config: &Config) -> CargoResult<bool> {
5252
None => return Ok(false),
5353
};
5454
if resolve_executable(Path::new("man")).is_ok() {
55-
let man = match extract_man(&subcommand, "1")? {
55+
let man = match extract_man(&subcommand, "1") {
5656
Some(man) => man,
5757
None => return Ok(false),
5858
};
5959
write_and_spawn(&man, "man")?;
6060
} else {
61-
let txt = match extract_man(&subcommand, "txt")? {
61+
let txt = match extract_man(&subcommand, "txt") {
6262
Some(txt) => txt,
6363
None => return Ok(false),
6464
};
@@ -96,10 +96,12 @@ fn check_alias(config: &Config, subcommand: &str) -> Option<String> {
9696
/// Extracts the given man page from the compressed archive.
9797
///
9898
/// Returns None if the command wasn't found.
99-
fn extract_man(subcommand: &str, extension: &str) -> CargoResult<Option<Vec<u8>>> {
99+
fn extract_man(subcommand: &str, extension: &str) -> Option<Vec<u8>> {
100100
let extract_name = OsString::from(format!("cargo-{}.{}", subcommand, extension));
101101
let gz = GzDecoder::new(COMPRESSED_MAN);
102102
let mut ar = tar::Archive::new(gz);
103+
// Unwraps should be safe here, since this is a static archive generated
104+
// by our build script. It should never be an invalid format!
103105
for entry in ar.entries().unwrap() {
104106
let mut entry = entry.unwrap();
105107
let path = entry.path().unwrap();
@@ -108,9 +110,9 @@ fn extract_man(subcommand: &str, extension: &str) -> CargoResult<Option<Vec<u8>>
108110
}
109111
let mut result = Vec::new();
110112
entry.read_to_end(&mut result).unwrap();
111-
return Ok(Some(result));
113+
return Some(result);
112114
}
113-
Ok(None)
115+
None
114116
}
115117

116118
/// Write the contents of a man page to disk and spawn the given command to

0 commit comments

Comments
 (0)