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