fn main() { let first:&str = "First"; let middle:&str = "Middle"; let lastname:&str = "Last"; let left:&str = "Left"; let center:&str = "Center"; let right:&str = "Right"; let favorite:&str = "kerfuffle"; let i1:i64 = 3261963; let i2:i16 = -42; let fp1:f64 = 3.1415926f64; let fp2:f64 = 2.99792458e9f64; let fp3:f64 = -1.234e-4f64; let mut s:String = format!("{2}, {0} {1}", first, middle, lastname); println!("{}", s); s = format!("{0} {1} {2}", left, center, right); println!("{}", s); s = format!("Favorite number is {0}", i1); println!("{}", s); s = format!("Favorite FP is {0}", fp1); println!("{}", s); let mut c:i32 = favorite[0]; println!("{}", format!("Favorite c is {0:c}", c)); println!("{}", format!("Favorite 11c is |{0:11c}|", c)); println!("{}", format!("Favorite <11c is |{0:<11c}|", c)); println!("{}", format!("Favorite ^11c is |{0:^11c}|", c)); println!("{}", format!("Favorite >11c is |{0:>11c}|", c)); println!("{}", format!("Favorite .<11c is |{0:.<11c}|", c)); println!("{}", format!("Favorite _^11c is |{0:_^11c}|", c)); println!("{}", format!("Favorite >11c is |{0: >11c}|", c)); c = 0x1F92F; println!("{}", format!("Favorite emoji c is {0:c}", c)); println!("{}", format!("Favorite s is {0:s}", favorite)); println!("{}", format!("Favorite .2s is {0:.2s}", favorite)); println!("{}", format!("Favorite 11s is |{0:11s}|", favorite)); println!("{}", format!("Favorite 11.2s is |{0:11.2s}|", favorite)); println!("{}", format!("Favorite <11.2s is |{0:<11.2s}|", favorite)); println!("{}", format!("Favorite ^11.2s is |{0:^11.2s}|", favorite)); println!("{}", format!("Favorite >11.2s is |{0:>11.2s}|", favorite)); println!("{}", format!("Favorite .<11.2s is |{0:.<11.2s}|", favorite)); println!("{}", format!("Favorite *^11.2s is |{0:*^11.2s}|", favorite)); println!("{}", format!("Favorite ->11.2s is |{0:->11.2s}|", favorite)); println!("{}", format!("Favorite d is {0:d}", i1)); println!("{}", format!("Another d is {0:d}", i2)); println!("{}", format!("Favorite b is {0:b}", i1)); println!("{}", format!("Another B is {0:b}", i2)); println!("{}", format!("Favorite o is {0:o}", i1)); println!("{}", format!("Another o is {0:o}", i2)); println!("{}", format!("Favorite x is {0:x}", i1)); println!("{}", format!("Another X is {0:X}", i2)); println!("{}", format!("Favorite #b is {0:#b}", i1)); println!("{}", format!("Another #B is {0:#b}", i2)); println!("{}", format!("Favorite #o is {0:#o}", i1)); println!("{}", format!("Another #o is {0:#o}", i2)); println!("{}", format!("Favorite #x is {0:#x}", i1)); println!("{}", format!("Another #X is {0:#X}", i2)); println!("{}", format!("Favorite 11d is |{0:11d}|", i1)); println!("{}", format!("Favorite +11d is |{0:+11d}|", i1)); println!("{}", format!("Favorite 011d is |{0:011d}|", i1)); println!("{}", format!("Favorite 011x is |{0:011x}|", i1)); println!("{}", format!("Favorite #011x is |{0:#011x}|", i1)); println!("{}", format!("Favorite f is {0:f}", fp1)); println!("{}", format!("Another f is {0:f}", fp2)); println!("{}", format!("One more f is {0:f}", fp3)); println!("{}", format!("Favorite e is {0:e}", fp1)); println!("{}", format!("Another e is {0:e}", fp2)); println!("{}", format!("One more e is {0:e}", fp3)); println!("{}", format!("Favorite g is {0:g}", fp1)); println!("{}", format!("Another g is {0:g}", fp2)); println!("{}", format!("One more g is {0:g}", fp3)); println!("{}", format!("Favorite .2f is {0:.2f}", fp1)); println!("{}", format!("Another .2f is {0:.2f}", fp2)); println!("{}", format!("One more .2f is {0:.2f}", fp3)); println!("{}", format!("Favorite .2e is {0:.2e}", fp1)); println!("{}", format!("Another .2e is {0:.2e}", fp2)); println!("{}", format!("One more .2e is {0:.2e}", fp3)); println!("{}", format!("Favorite .2g is {0:.2g}", fp1)); println!("{}", format!("Another .2g is {0:.2g}", fp2)); println!("{}", format!("One more .2g is {0:.2g}", fp3)); println!("{}", format!("Favorite 15.2f is |{0:15.2f}|", fp1)); println!("{}", format!("Another 15.2e is |{0:15.2e}|", fp2)); println!("{}", format!("One more 15.2g is |{0:15.2g}|", fp3)); }