mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-22 20:19:42 +00:00
Further clarification on the benefits of passing in immutable slices to functions
This commit is contained in:
@ -113,7 +113,7 @@ fn main() {
|
||||
### Slicing
|
||||
Immutable or mutable slices of Vecs can be taken, using `&` or `&mut, respectively.
|
||||
|
||||
In Rust, it’s more common to pass immutable slices as arguments rather than vectors when you just want to provide read access. The same goes for `String` and `&str`.
|
||||
In Rust, it’s more common to pass immutable slices as arguments rather than vectors when you just want to provide read access, as this is more flexible (no move) and efficient (no copy). The same goes for `String` and `&str`.
|
||||
|
||||
5. 🌟🌟
|
||||
```rust,editable
|
||||
|
Reference in New Issue
Block a user