File tree 3 files changed +443
-1036
lines changed
3 files changed +443
-1036
lines changed Original file line number Diff line number Diff line change @@ -96,13 +96,6 @@ pub use indexmap::{
96
96
pub use indexset:: { FnvIndexSet , IndexSet , Iter as IndexSetIter } ;
97
97
pub use linear_map:: LinearMap ;
98
98
pub 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 _;
106
99
pub use vec:: { Vec , VecView } ;
107
100
108
101
#[ macro_use]
@@ -114,8 +107,9 @@ mod histbuf;
114
107
mod indexmap;
115
108
mod indexset;
116
109
mod linear_map;
110
+ pub mod storage;
117
111
pub mod string;
118
- mod vec;
112
+ pub mod vec;
119
113
120
114
#[ cfg( feature = "serde" ) ]
121
115
mod 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