2 ms·
Thank you, yes. Is there a binding between the "top" pointer &mut T, and the string which the pointer/length pair points to? Can we change our pointer to poin
by e12e 8y ago
Thank you, yes.
Is there a binding between the "top" pointer &mut T, and the string which the pointer/length pair points to?
Can we change our pointer to point somewhere else entirely, say a newly allocated string "goodbye, world"?
p1
\------\
V
(p2, 11) (p3, 13)
| \
| \
| \
V V
Hello World Goodbye World
- steveklabnik 8y agoThere's no inherent connection; you could absolutely do this.
- russed 8y agoTo restrict in the manner that the person above described would require some kind of const parameter in the type, no? The type would need to be parameterized over the `&str` to ensure that slices could only be taken from that particular string.
- steveklabnik 8y agoI believe that’s correct.