Guest User

Untitled

a guest
May 20th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. struct Foo(u8);
  2. struct Bar(u8);
  3. struct Baz(u8);
  4.  
  5. impl From<Baz> for Bar {
  6. fn from(t: Baz) -> Bar {
  7. Bar(t.0)
  8. }
  9. }
  10.  
  11. impl<T: Into<Bar>> From<T> for Foo {
  12. fn from(t: T) -> Foo {
  13. Foo(t.into().0)
  14. }
  15. }
  16.  
  17. fn main() {
  18. let b = Baz(42);
  19. let f: Foo = b.into();
  20. }
Add Comment
Please, Sign In to add comment