rust-unofficial / patterns

A catalogue of Rust design patterns, anti-patterns and idioms
https://rust-unofficial.github.io/patterns/
Mozilla Public License 2.0
7.85k stars 354 forks source link

Rephrase statement in Deref: "Collections are smart pointers" #257

Open StrayLittlePunk opened 3 years ago

StrayLittlePunk commented 3 years ago

Disadvantages Methods and traits only available via dereferencing are not taken into account when bounds checking, so generic programming with data structures using this pattern can get complex (see the Borrow and AsRef traits, etc.). why method and traits only available via dereferencing are not taken into account when bounds checking ?

MarcoIeni commented 3 years ago

I agree it's really complicated. If someone wants to improve this a PR is welcome.

pickfire commented 3 years ago

I don't understand that sentence itself. I thought bound checks are usually eliminated when using collections and iterator method?

StrayLittlePunk commented 3 years ago

@pickfire I don't think so, it said method and trait are not taken into account. the statement link at below Original Statement link

StrayLittlePunk commented 3 years ago

@MarcoIeni I think so too