File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,13 +96,6 @@ pub use indexmap::{
9696pub use indexset:: { FnvIndexSet , IndexSet , Iter as IndexSetIter } ;
9797pub use linear_map:: LinearMap ;
9898pub use string:: String ;
99-
100- // Workaround https://github.com/rust-lang/rust/issues/119015. This is required so that the methods on `VecView` and `Vec` are properly documented.
101- // cfg(doc) prevents `VecInner` being part of the public API.
102- // doc(hidden) prevents the `pub use vec::VecInner` from being visible in the documentation.
103- #[ cfg( doc) ]
104- #[ doc( hidden) ]
105- pub use vec:: VecInner as _;
10699pub use vec:: { Vec , VecView } ;
107100
108101#[ macro_use]
@@ -114,8 +107,9 @@ mod histbuf;
114107mod indexmap;
115108mod indexset;
116109mod linear_map;
110+ pub mod storage;
117111pub mod string;
118- mod vec;
112+ pub mod vec;
119113
120114#[ cfg( feature = "serde" ) ]
121115mod de;
Original file line number Diff line number Diff line change 1+ //! `Storage` trait defining how data is stored in a container.
2+
3+ use core:: borrow:: { Borrow , BorrowMut } ;
4+
5+ pub ( crate ) trait SealedStorage {
6+ type Buffer < T > : ?Sized + Borrow < [ T ] > + BorrowMut < [ T ] > ;
7+ }
8+
9+ /// Trait defining how data for a container is stored.
10+ ///
11+ /// There's two implementations available:
12+ ///
13+ /// - [`OwnedStorage`]: stores the data in an array `[T; N]` whose size is known at compile time.
14+ /// - [`ViewStorage`]: stores the data in an unsized `[T]`.
15+ ///
16+ /// This allows containers to be generic over either sized or unsized storage.
17+ ///
18+ /// This trait is sealed, so you cannot implement it for your own types. You can only use
19+ /// the implementations provided by this crate.
20+ #[ allow( private_bounds) ]
21+ pub trait Storage : SealedStorage { }
22+
23+ /// Implementation of [`Storage`] that stores the data in an array `[T; N]` whose size is known at compile time.
24+ pub enum OwnedStorage < const N : usize > { }
25+ impl < const N : usize > Storage for OwnedStorage < N > { }
26+ impl < const N : usize > SealedStorage for OwnedStorage < N > {
27+ type Buffer < T > = [ T ; N ] ;
28+ }
29+
30+ /// Implementation of [`Storage`] that stores the data in an unsized `[T]`.
31+ pub enum ViewStorage { }
32+ impl Storage for ViewStorage { }
33+ impl SealedStorage for ViewStorage {
34+ type Buffer < T > = [ T ] ;
35+ }
You can’t perform that action at this time.
0 commit comments