Is Deref for accessing underlying collection idiomatic Rust?

Hi all,

I was wondering whether it was considered as idiomatic Rust to implement Deref for accessing a collection in this case:

struct S<T> {
    v: Vec<T>,
}

Then all iterators are accessible through Deref if implemented (like iterating over S is iterating over v)?

You’re probably looking for AsRef<[T]>; Deref is more for smart pointer semantics.

Thanks @vitalyd, I'll have a look at AsRef.