Hello,
I’m trying to transfert the content of a file in another file (created by the application)
fn openfile(file: String, name: &str) -> Result<File, io::Error> {
let mut f = File::open(file)?;
let mut e = File::open(name)?;
let mut s = String::new();
f.read_to_string(&mut s)?;
println!("{}\n\n", s);
match e.write_all(&mut s.as_bytes()) {
Err(why) => {
panic!("couldn't write to {}: {}", name, why.description())
},
Ok(_) => println!("successfully wrote to {}", name),
}
Ok(f)
}
The println print correctly the content of a file but the write_all function panic.
“other os error”.
How can I do what I want to do ?
Another question (while i’m here), did I use the question mark operator correcty ?
Thanks for the help