From fc7a5ee342baa6968bc2256d7b99696e51a897b8 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Wed, 31 Aug 2016 10:08:33 -0400 Subject: [PATCH] Working through rustbyexample --- rustbyexample/.gitignore | 1 + rustbyexample/01/Cargo.lock | 4 ++++ rustbyexample/01/Cargo.toml | 6 ++++++ rustbyexample/01/src/main.rs | 23 +++++++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 rustbyexample/.gitignore create mode 100644 rustbyexample/01/Cargo.lock create mode 100644 rustbyexample/01/Cargo.toml create mode 100644 rustbyexample/01/src/main.rs diff --git a/rustbyexample/.gitignore b/rustbyexample/.gitignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/rustbyexample/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/rustbyexample/01/Cargo.lock b/rustbyexample/01/Cargo.lock new file mode 100644 index 0000000..00e1fed --- /dev/null +++ b/rustbyexample/01/Cargo.lock @@ -0,0 +1,4 @@ +[root] +name = "01" +version = "0.1.0" + diff --git a/rustbyexample/01/Cargo.toml b/rustbyexample/01/Cargo.toml new file mode 100644 index 0000000..84b0d89 --- /dev/null +++ b/rustbyexample/01/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "01" +version = "0.1.0" +authors = ["Dan Buch "] + +[dependencies] diff --git a/rustbyexample/01/src/main.rs b/rustbyexample/01/src/main.rs new file mode 100644 index 0000000..5a9057a --- /dev/null +++ b/rustbyexample/01/src/main.rs @@ -0,0 +1,23 @@ +fn main() { + println!("{} days", 31); + + println!("{0}, this is {1}. {1}, this is {0}", "Alice", "Bob"); + + println!("{subject} {verb} {object}", + object="the lazy dog", + subject="the quick brown fox", + verb="jumps over"); + + println!("{} of {:b} people know binary, the other half don't", 1, 2); + + println!("{number:>width$}", number=1, width=6); + + println!("{number:0>width$}", number=1, width=6); + + println!("My name is {0}, {1} {0}", "Bond", "James"); + +#[allow(dead_code)] + struct Structure(i32); + + // println!("This struct `{}` won't print...", Structure(3)); +}