Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. //use std::fmt::Debug;
  2. //use std::io;
  3.  
  4. fn main() {
  5. /*println!("Hello, world!");
  6. println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
  7. println!("{number:>width$}", number=1, width=6);
  8. println!("My name is {0}, {1} {0}", " Bond","james");*/
  9.  
  10. #[derive(Debug)]
  11. struct Structure(i32);
  12. // However, custom types such as this structure require more complicated
  13. // handling. This will not work.
  14. println!("{:?}", Structure(3));
  15.  
  16. let formatted_number = format!("{:.*}",2,1.234567);
  17. assert_eq!("1.23", formatted_number);
  18. println!("{}",formatted_number);
  19.  
  20. let pi = 3.141592;
  21. let formatted_pi = format!("{:.*}",3, pi);
  22. println!("Pi is roughly {}", formatted_pi);
  23.  
  24. println!("{}", format!("{:.*}",3, 3.141592));
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement