Skip to content

Commit

Permalink
learning in stages
Browse files Browse the repository at this point in the history
  • Loading branch information
MatrixMike committed Sep 19, 2019
1 parent a85d159 commit 139369a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Types1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
struct Point<T> {
x: T,
y: T,
}

fn main() {
let integer = Point { x: 5, y: 10 };
let float = Point { x: 1.0, y: 4.0 };
}
32 changes: 32 additions & 0 deletions serdeTest1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
extern crate csv;
#[macro_use]
extern crate serde_derive;

#[derive(Deserialize)]
struct Record {
year: u16,
make: String,
model: String,
description: String,
}

fn run() -> Result<()> {
let csv = "year,make,model,description
1948,Porsche,356,Luxury sports car
1967,Ford,Mustang fastback 1967,American car";

let mut reader = csv::Reader::from_reader(csv.as_bytes());

for record in reader.deserialize() {
let record: Record = record?;
println!(
"In {}, {} built the {} model. It is a {}.",
record.year,
record.make,
record.model,
record.description
);
}

Ok(())
}

0 comments on commit 139369a

Please sign in to comment.