Guest User

Untitled

a guest
Oct 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. //#![feature(specialization)]
  2. extern crate serde; // 1.0.78
  3. extern crate serde_json; // 1.0.27
  4. #[macro_use] extern crate serde_derive; // 1.0.78
  5.  
  6. // #[derive(Debug, Serialize)]
  7. struct X {
  8. foo: String,
  9. }
  10.  
  11. trait AlwaysDebug {
  12. fn always_debug(&self) -> Option<String>;
  13. }
  14.  
  15. impl<T: std::fmt::Debug> AlwaysDebug for T {
  16. fn always_debug(&self) -> Option<String> {
  17. None
  18. }
  19. }
  20.  
  21. fn main() {
  22. let x = X{foo: "Foo Bar".to_string()};
  23. println!("{:?}", x.always_debug());
  24. // println!("{:?}", x);
  25. // println!("{:?}", serde_json::to_string(&x).unwrap());
  26. }
Add Comment
Please, Sign In to add comment