about summary refs log tree commit diff
path: root/tests/ui/autoref-autoderef/autoderef-vec-to-slice-by-value.rs
blob: 4d67c3a6733bdda1aafff80423ee0c42666fbfba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Tests that a `Vec<isize>` can call a method defined in a trait (`Foo`)
//! implemented for `&[isize]` with a by-value receiver (`self`), relying on auto-dereferencing
//! from `Vec` to `&[isize]` during method resolution.

//@ run-pass

trait Foo {
    fn foo(self);
}

impl<'a> Foo for &'a [isize] {
    fn foo(self) {}
}

pub fn main() {
    let items = vec![ 3, 5, 1, 2, 4 ];
    items.foo();
}