Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #![feature(specialization)]
  2.  
  3. use std::ops::Deref;
  4. pub struct UserId(i64);
  5.  
  6. impl<S> From<S> for UserId
  7. where
  8. S: Deref,
  9. S::Target: Into<UserId>,
  10. {
  11. default fn from(s: S) -> Self {
  12. s.deref().into()
  13. }
  14. }
  15.  
  16. impl From<i64> for UserId {
  17. fn from(id: i64) -> Self {
  18. UserId(id)
  19. }
  20. }
  21.  
  22. fn main() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement