Skip to content

Commit 51cfe8d

Browse files
committed
storage: expand docs for trait with an example of where it's used.
1 parent 5cac42f commit 51cfe8d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/storage.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ pub(crate) trait SealedStorage {
1313
/// - [`OwnedStorage`]: stores the data in an array `[T; N]` whose size is known at compile time.
1414
/// - [`ViewStorage`]: stores the data in an unsized `[T]`.
1515
///
16-
/// This allows containers to be generic over either sized or unsized storage.
16+
/// This allows containers to be generic over either sized or unsized storage. For example,
17+
/// the [`vec`](crate::vec) module contains a [`VecInner`](crate::vec::VecInner) struct
18+
/// that's generic on [`Storage`], and two type aliases for convenience:
19+
///
20+
/// - [`Vec<T, N>`](crate::vec::Vec) = `VecInner<T, OwnedStorage<N>>`
21+
/// - [`VecView<T>`](crate::vec::VecView) = `VecInner<T, ViewStorage>`
22+
///
23+
/// `Vec` can be unsized into `VecView`, either by unsizing coercions such as `&mut Vec -> &mut VecView` or
24+
/// `Box<Vec> -> Box<VecView>`, or explicitly with [`.as_view()`](crate::vec::Vec::as_view) or [`.as_mut_view()`](crate::vec::Vec::as_mut_view).
1725
///
1826
/// This trait is sealed, so you cannot implement it for your own types. You can only use
1927
/// the implementations provided by this crate.

0 commit comments

Comments
 (0)