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;
|
||||
|
||||
/// no argument for target; code 1
|
||||
pub fn missing_target() {
|
||||
pub fn missing_target() -> ! {
|
||||
eprintln!("mkwin: missing target");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/// 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?");
|
||||
exit(2);
|
||||
}
|
||||
|
|
|
@ -73,15 +73,9 @@ pub fn main() {
|
|||
if let Ok(path) = path.canonicalize() {
|
||||
let path: String = path.to_string_lossy().into();
|
||||
target = format!("'{path}'");
|
||||
} else {
|
||||
error::canonicalize_fail(arg);
|
||||
return;
|
||||
}
|
||||
} else { error::canonicalize_fail(arg); }
|
||||
}
|
||||
} else {
|
||||
error::missing_target();
|
||||
return;
|
||||
}
|
||||
} else { error::missing_target(); }
|
||||
|
||||
// construct output
|
||||
println!("#!/usr/bin/bash\n# generated with: mkwin{arg_string}\n");
|
||||
|
|
Loading…
Reference in a new issue