diff options
author | Adam Carpenter <53hornet@gmail.com> | 2019-03-27 15:32:37 -0400 |
---|---|---|
committer | Adam Carpenter <53hornet@gmail.com> | 2019-03-27 15:32:37 -0400 |
commit | 67cdcc2e12118becb823e20a40cc2687f2b8425a (patch) | |
tree | ed92c3234b89079e6d4cf36f5e80c5ffa79def48 /errors | |
parent | e25482fca375d318a39c3b54db396b0db6e0b263 (diff) | |
download | learning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.tar.xz learning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.zip |
Started Rust in Action MEAP.
Diffstat (limited to 'errors')
-rw-r--r-- | errors/Cargo.lock | 4 | ||||
-rw-r--r-- | errors/Cargo.toml | 7 | ||||
-rw-r--r-- | errors/src/main.rs | 38 |
3 files changed, 0 insertions, 49 deletions
diff --git a/errors/Cargo.lock b/errors/Cargo.lock deleted file mode 100644 index 749984f..0000000 --- a/errors/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[[package]] -name = "errors" -version = "0.1.0" - diff --git a/errors/Cargo.toml b/errors/Cargo.toml deleted file mode 100644 index e531a1b..0000000 --- a/errors/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "errors" -version = "0.1.0" -authors = ["Adam Carpenter <adam.carpenter@adp.com>"] -edition = "2018" - -[dependencies] diff --git a/errors/src/main.rs b/errors/src/main.rs deleted file mode 100644 index 1250677..0000000 --- a/errors/src/main.rs +++ /dev/null @@ -1,38 +0,0 @@ -use std::io; -use std::io::Read; -use std::fs::File; -//use std::io::ErrorKind; - -fn read_username_from_file() -> Result<String, io::Error> { -// let f = File::open("hello.txt"); -// let mut f = match f { -// Ok(file) => file, -// Err(e) => return Err(e), -// }; -// let mut s = String::new(); -// match f.read_to_string(&mut s) { -// Ok(_) => Ok(s), -// Err(e) => Err(e), -// } - let mut s = String::new(); - File::open("hello.txt")?.read_to_string(&mut s)?; - Ok(s) -} -fn main() { -// let f = File::open("hello.txt").map_err(|error| { -// if error.kind() == ErrorKind::NotFound { -// File::create("hello.txt").unwrap_or_else(|error| { -// panic!("Could not create file: {:?}", error); -// }) -// } -// else { -// panic!("Problem opening file: {:?}", error); -// } -// }); - - //let f = File::open("hello.txt").unwrap(); - - //let f = File::open("hello.txt").expect("failed to open hello.txt"); - - dbg!(read_username_from_file()); -} |