Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Foo {
- fn foo(&self) -> u32;
- }
- impl<'a> Foo for &'a [u32] {
- fn foo(&self) -> u32 {
- self[0]
- }
- }
- fn bar(f: impl Foo) -> u32 {
- f.foo()+1
- }
- fn main() {
- let f:&[u32] = &[42];
- println!("{}", bar(f));
- }
Add Comment
Please, Sign In to add comment