note on not-too-large slices

pull/162/head
Ralf Jung 6 years ago
parent 8db5ad17bf
commit 78c247398f

@ -50,8 +50,10 @@ points to are part of the same allocation (so in particular they all have to be
part of *some* allocation). The span of bytes it points to is determined by the part of *some* allocation). The span of bytes it points to is determined by the
pointer value and the size of the pointee type. As a consequence, if the span is pointer value and the size of the pointee type. As a consequence, if the span is
empty, "dangling" is the same as "non-null". Note that slices point to their empty, "dangling" is the same as "non-null". Note that slices point to their
entire range, so it's very important that the length metadata is never too entire range, so it's very important that the length metadata is never too large
large. If for some reason this is too cumbersome, consider using raw pointers. (in particular, allocations and therefore slices cannot be bigger than
`isize::MAX` bytes). If for some reason this is too cumbersome, consider using
raw pointers.
That's it. That's all the causes of Undefined Behavior baked into Rust. Of That's it. That's all the causes of Undefined Behavior baked into Rust. Of
course, unsafe functions and traits are free to declare arbitrary other course, unsafe functions and traits are free to declare arbitrary other

Loading…
Cancel
Save