Guest User

Untitled

a guest
May 27th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. trait Foo {
  2. fn foo(&self) -> u32;
  3. }
  4.  
  5. impl<'a> Foo for &'a [u32] {
  6. fn foo(&self) -> u32 {
  7. self[0]
  8. }
  9. }
  10.  
  11. fn bar(f: impl Foo) -> u32 {
  12. f.foo()+1
  13. }
  14.  
  15. fn main() {
  16. let f:&[u32] = &[42];
  17. println!("{}", bar(f));
  18. }
Add Comment
Please, Sign In to add comment