Guest User

Untitled

a guest
May 16th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. use std::fmt::Debug;
  2.  
  3. fn main() {
  4. println!("whee: {:?}, {:?}", whee(5u32), whee(6u64));
  5. println!(
  6. "mwahaha: {:?}, {:?}",
  7. mwahaha(true, 5u32, 6u64),
  8. mwahaha(false, 7u64, 8u32)
  9. );
  10. }
  11.  
  12. // I was slightly surprised you can do this:
  13. fn whee(x: impl Debug) -> impl Debug {
  14. x
  15. }
  16.  
  17. // But this you can't:
  18. fn mwahaha(p: bool, x: impl Debug, y: impl Debug) -> impl Debug {
  19. if p {
  20. x
  21. } else {
  22. y
  23. }
  24. }
Add Comment
Please, Sign In to add comment