You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But this code opens the file as read only, it should open it for writing or creating a new file, for example :
let file = File::create(&Path::new("message.txt"));
It also generates two warnings :
buff_writer.rs:7:2: 7:35 warning: unused result which must be used, #[warn(unused_must_use)] on by default
buff_writer.rs:7 writer.write_str("hello, world");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
buff_writer.rs:8:2: 8:17 warning: unused result which must be used, #[warn(unused_must_use)] on by default
buff_writer.rs:8 writer.flush();
by unwrap()ing both these remove the errors, and in the case where File::open is used to successfully crash the sample app when attempting to append to a read only file.