Guest User

Untitled

a guest
Apr 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. trait Convert<'a, T: 'a> {
  2. fn convert(&self) -> Option<T>;
  3. }
  4.  
  5. struct MyStruct;
  6. impl<'a> Convert<'a, bool> for MyStruct {
  7. fn convert(&self) -> Option<bool> {
  8. Some(true)
  9. }
  10. }
  11.  
  12. impl<'a> Convert<'a, usize> for MyStruct {
  13. fn convert(&self) -> Option<usize> {
  14. Some(1)
  15. }
  16. }
  17.  
  18. fn main() {
  19. if let Some(_) = Convert::<usize>::convert(&MyStruct) {
  20.  
  21. }
  22. }
Add Comment
Please, Sign In to add comment