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.29 KB | None | 0 0
  1. use std::ops::Deref;
  2. pub struct UserId(i64);
  3.  
  4. impl From<i64> for UserId {
  5. fn from(id: i64) -> Self {
  6. UserId(id)
  7. }
  8. }
  9.  
  10. impl<S> From<S> for UserId
  11. where
  12. S: Deref,
  13. S::Target: Into<UserId>,
  14. {
  15. fn from(s: S) -> Self {
  16. s.deref().into()
  17. }
  18. }
  19.  
  20. fn main() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement