mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-21 15:35:53 +02:00
Add note that slices can't grow (#2663)
This commit is contained in:
parent
bf4e4e34ee
commit
b4301e06c4
@ -42,4 +42,13 @@ fn main() {
|
||||
- Slices always borrow from another object. In this example, `a` has to remain
|
||||
'alive' (in scope) for at least as long as our slice.
|
||||
|
||||
- You can't "grow" a slice once it's created:
|
||||
- You can't append elements of the slice, since it doesn't own the backing
|
||||
buffer.
|
||||
- You can't grow a slice to point to a larger section of the backing buffer.
|
||||
The slice loses information about the underlying buffer and so you can't
|
||||
know how larger the slice can be grown.
|
||||
- To get a larger slice you have to back to the original buffer and create a
|
||||
larger slice from there.
|
||||
|
||||
</details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user