error methods now have the correct return type
This commit is contained in:
parent
ed26c60ceb
commit
72d6902136
2 changed files with 4 additions and 10 deletions
|
@ -3,13 +3,13 @@
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
/// no argument for target; code 1
|
/// no argument for target; code 1
|
||||||
pub fn missing_target() {
|
pub fn missing_target() -> ! {
|
||||||
eprintln!("mkwin: missing target");
|
eprintln!("mkwin: missing target");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// failed to canonicalize target path; code 2
|
/// failed to canonicalize target path; code 2
|
||||||
pub fn canonicalize_fail(target: String) {
|
pub fn canonicalize_fail(target: String) -> ! {
|
||||||
eprintln!("mkwin: failed to canonicalze '{target}'--does the file exist?");
|
eprintln!("mkwin: failed to canonicalze '{target}'--does the file exist?");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,15 +73,9 @@ pub fn main() {
|
||||||
if let Ok(path) = path.canonicalize() {
|
if let Ok(path) = path.canonicalize() {
|
||||||
let path: String = path.to_string_lossy().into();
|
let path: String = path.to_string_lossy().into();
|
||||||
target = format!("'{path}'");
|
target = format!("'{path}'");
|
||||||
} else {
|
} else { error::canonicalize_fail(arg); }
|
||||||
error::canonicalize_fail(arg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else { error::missing_target(); }
|
||||||
error::missing_target();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// construct output
|
// construct output
|
||||||
println!("#!/usr/bin/bash\n# generated with: mkwin{arg_string}\n");
|
println!("#!/usr/bin/bash\n# generated with: mkwin{arg_string}\n");
|
||||||
|
|
Loading…
Reference in a new issue