Why &mut is working in this case, when method takes ownership

Hi,
I’m struggling to understand why and how this code works:

fn iter1() {
    let samples = vec![1, 2, 3];
    let mut iter = samples.into_iter();
    for i in 0..3 {
        let n = (&mut iter).count();
        println!("Iterator has {} items", n)
    }
}

count method takes ownership of the iterator. So without &mut it’ll give obvious “use of moved value” error. But with &mut it works. However if it would just dereference, it should give error “cannot move out of borrowed content”? What exactly is happening in background?

Emphasis on the “if”. It doesn’t give that error because it isn’t just dereferencing.

If you look at the documentation for Iterator, you’ll see there’s an implementation for &mut I where I: Iterator.

Thanks. I see now, pretty cool.