Skip to content

Commit 4c57882

Browse files
authored
Rollup merge of #64703 - llogiq:slices-elems-are-equidistant, r=rkruppe
Docs: slice elements are equidistant Recently, someone asked why `[char]` and `str` are not interchangeable, and I explained that in a slice, the elements must be laid out equidistantly, whereas the chars in a `str` are stored compactly regardless their size. However I couldn't find this documented anywhere, so here's a small addition of this fact.
2 parents c6f87c2 + 6ccb7ae commit 4c57882

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libstd/primitive_docs.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,9 @@ mod prim_array { }
566566
#[doc(alias = "[")]
567567
#[doc(alias = "]")]
568568
#[doc(alias = "[]")]
569-
/// A dynamically-sized view into a contiguous sequence, `[T]`.
569+
/// A dynamically-sized view into a contiguous sequence, `[T]`. Contiguous here
570+
/// means that elements are layed out so that every element is the same
571+
/// distance from its neighbors.
570572
///
571573
/// *[See also the `std::slice` module](slice/index.html).*
572574
///

0 commit comments

Comments
 (0)