Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #![allow(unused)]
  2. // Hello {arg 0 ("x")} is {arg 1 (0.01) with precision specified inline (5)}
  3. fn main() {
  4. println!("Hello {0} is {1:.5}", "x", 0.01);
  5.  
  6. // Hello {arg 1 ("x")} is {arg 2 (0.01) with precision specified in arg 0 (5)}
  7. println!("Hello {1} is {2:.0$}", 5, "x", 0.01);
  8.  
  9. // Hello {arg 0 ("x")} is {arg 2 (0.01) with precision specified in arg 1 (5)}
  10. println!("Hello {0} is {2:.1$}", "x", 5, 0.01);
  11.  
  12. // Hello {next arg ("x")} is {second of next two args (0.01) with precision
  13. // specified in first of next two args (5)}
  14. println!("Hello {} is {:.*}", "x", 5, 0.01);
  15.  
  16. // Hello {next arg ("x")} is {arg 2 (0.01) with precision
  17. // specified in its predecessor (5)}
  18. println!("Hello {} is {2:.*}", "x", 5, 0.01);
  19.  
  20. // Hello {next arg ("x")} is {arg "number" (0.01) with precision specified
  21. // in arg "prec" (5)}
  22. println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement