rust-unofficial / patterns

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

Using `&str` vs using `&String` #27

Closed cbreeden closed 3 years ago

cbreeden commented 8 years ago

This is a common idiom, where using an &str is often more flexible than using a &String.

MarcoIeni commented 3 years ago

Same is true for Path and PathBuf I believe, and also for Vec and slices. There is also a clippy lint about this (works only with nightly): https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg We should express this concept in a general way and add it to idioms.

simonsan commented 3 years ago

This issue should be fixed with #29 I believe, if not feel free to reopen.