Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. struct ND(u8);
  2.  
  3. impl Drop for ND {
  4. fn drop(&mut self) {
  5. dbg!(self.0);
  6. }
  7. }
  8.  
  9. impl ND {
  10. fn foo(&self) -> u8 {
  11. self.0
  12. }
  13. }
  14.  
  15. macro_rules! format2 {
  16. ($($arg:tt)*) => {{
  17. let res = std::fmt::format(core::format_args!($($arg)*));
  18. res
  19. }}
  20. }
  21.  
  22. fn main() {
  23. match format2!("{}", ND(0).foo()) {
  24. _ => dbg!("foo"),
  25. };
  26.  
  27. dbg!();
  28.  
  29. match format!("{}", ND(0).foo()) {
  30. _ => dbg!("bar"),
  31. };
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement