box-o-sand/rustbyexample/01/src/main.rs

27 lines
695 B
Rust
Raw Normal View History

2016-08-31 14:08:33 +00:00
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));
2016-08-31 14:11:27 +00:00
let pi = 3.141592;
println!("Pi is roughly {:.*}", 3, pi);
2016-08-31 14:08:33 +00:00
}