use std::fs::File;
use std::io::prelude::Write;
use std::io::ErrorKind;
fn main() {
let mut f = File::open("story.txt").unwrap_or_else(|err| {
if err.kind() == ErrorKind::NotFound {
File::create("story.txt").unwrap()
} else {
panic!("{}", err);
}
});
match f.write(b"This is my story") {
Ok(_) => println!("The story was written."),
Err(e) => panic!("{}", e),
}
}
If I go to let mut f = File::open("story.txt").u
$ racer complete 6 41 ./src/main.rs
PREFIX 125,126,u
MATCH unwrap,1002,11,/home/arthaclarius/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/result.rs,Function,pub fn unwrap(self) -> T
MATCH unwrap_err,1064,11,/home/arthaclarius/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/result.rs,Function,pub fn unwrap_err(self) -> E
MATCH unwrap_or,827,11,/home/arthaclarius/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/result.rs,Function,pub fn unwrap_or(self, default: T) -> T
MATCH unwrap_or_default,1102,11,/home/arthaclarius/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/result.rs,Function,pub fn unwrap_or_default(self) -> T
END
If you check the code I can use unwrap_or_else but is not in the complete suggestions.
If I go to match f.w
$ racer complete 14 13 ./src/main.rs
PREFIX 321,322,w
END
But I was expecting write, write_vectored, write_all, and even more.
Taking the
std::fs::File
example I writeIf I go to
let mut f = File::open("story.txt").u
If you check the code I can use
unwrap_or_else
but is not in the complete suggestions.If I go to
match f.w
But I was expecting
write
,write_vectored
,write_all
, and even more.Maybe I'm wrong but It should be working.