diff options
author | Adam Carpenter <gitlab@53hor.net> | 2019-07-13 12:13:20 -0400 |
---|---|---|
committer | Adam Carpenter <gitlab@53hor.net> | 2019-07-13 12:13:20 -0400 |
commit | deb21f09fa0912a1793c0b747aaeca14f439d29f (patch) | |
tree | e62bc3440b7cf2d4b83bb4aea1072d1b503591ea /meap/ch7/src | |
parent | 7e8ee5ed9cad6484e9f13f81731b102ced58402e (diff) | |
download | learning-rust-deb21f09fa0912a1793c0b747aaeca14f439d29f.tar.xz learning-rust-deb21f09fa0912a1793c0b747aaeca14f439d29f.zip |
Merging.
Diffstat (limited to 'meap/ch7/src')
-rw-r--r--[-rwxr-xr-x] | meap/ch7/src/main.rs | 109 |
1 files changed, 13 insertions, 96 deletions
diff --git a/meap/ch7/src/main.rs b/meap/ch7/src/main.rs index 1dbb471..933a55e 100755..100644 --- a/meap/ch7/src/main.rs +++ b/meap/ch7/src/main.rs @@ -1,100 +1,17 @@ -//#[macro_use] -//extern crate serde_derive; -// -//extern crate serde; -//extern crate serde_json; -//extern crate bincode; -// -//#[derive(Serialize, Deserialize)] -//struct City { -// name: String, -// population: usize, -// latitude: f64, -// longitude: f64, -//} -// -//fn main() { -// let calabar = City { -// name: String::from("Calabar"), -// population: 470_000, -// latitude: 4.95, -// longitude: 8.33, -// }; -// -// let as_json = serde_json::to_string(&calabar).unwrap(); -// let as_bincode = bincode::serialize(&calabar).unwrap(); -// -// println!("json: {}", &as_json); -// println!("bincode: {:?}", &as_bincode); -// println!("bincode utf8: {:?}", String::from_utf8_lossy(&as_bincode)); -//} +#[macro_use] +extern crate serde_derive; +extern crate serde; +extern crate serde_json; +extern crate bincode; - -//use std::io::prelude::*; -// -//const BYTES_PER_LINE: usize = 16; -//const INPUT: &'static [u8] = br#" -// -//fn main() { -// println!("hello world") -//}"#; -// -//fn main() -> std::io::Result<()> { -// let mut buffer: Vec<u8> = vec!(); -// INPUT.read_to_end(&mut buffer)?; -// -// let mut position_in_input = 0; -// -// for line in buffer.chunks(BYTES_PER_LINE) { -// print!("[0x{:08x}] ", position_in_input); -// -// for byte in line { -// print!("{:02x} ", byte); -// } -// -// println!(); -// position_in_input += BYTES_PER_LINE; -// } -// -// Ok(()) -//} - - -//use std::fs::File; -//use std::io::prelude::*; -//use std::env; -// -//const BYTES_PER_LINE: usize = 16; -// -//fn main() { -// let arg1 = env::args().nth(1); -// let fname = arg1.expect("usage: fview FILENAME"); -// -// let mut f = File::open(&fname).expect("unable to open file"); -// let mut pos = 0; -// let mut buffer = [0; BYTES_PER_LINE]; -// -// while let Ok(_) = f.read_exact(&mut buffer) { -// print!("[0x{:08x}] ", pos); -// -// for byte in &buffer { -// match *byte { -// 0x00 => print!(". "), -// 0xff => print!("## "), -// _ => print!("{:02x} ", byte), -// } -// } -// -// println!(""); -// pos += BYTES_PER_LINE; -// } -//} - - -use std::path::PathBuf; +#[derive(Serialize, Deserialize)] +struct City { + name: String, + population: usize, + latitude: f64, + longitude: f64, +} fn main() { - let mut hello = PathBuf::from("/tmp/hello.txt"); - hello.pop(); - println!("{:?}", hello.display()); + println!("Hi, world!"); } |