pub fn filehash(file_path: &mut String) -> Result<u64, Error>
Expand description
// A simple example of a program that queries the user
// for a file to hash and prints the result.
fn main() -> Result<(), Box<dyn Error>> {
let mut input_string = String::new();
println!("Path to the file:");
std::io::stdin().read_line(&mut input_string)?;
let result = filehash(&mut input_string);
match result {
Ok(value) => {
println!("{}", value);
return Ok(());
}
Err(err) => {
println!("Error: {}", err);
return Err(Box::new(err));
}
}
}
Examples found in repository?
examples/simple.rs (line 11)
5fn main() -> Result<(), Box<dyn Error>> {
6 println!("Path to the file:");
7
8 let mut input_string = String::new();
9 std::io::stdin().read_line(&mut input_string)?;
10
11 let result = filehash(&mut input_string);
12
13 match result {
14 Ok(value) => {
15 println!("{}", value);
16 return Ok(());
17 }
18 Err(err) => {
19 println!("Error: {}", err);
20 return Err(Box::new(err));
21 }
22 }
23}