@@ -23,8 +23,7 @@ This crate is `no_std` compatible, just turn off all default features.
2323
2424## Basic Usage
2525
26- On stable ` no_std ` you have four choices on for which storage you can use
27- ` SliceVec ` , ` InitSliceVec ` , ` TypeVec ` , and ` ZSVec ` .
26+ #### ` SliceVec ` and ` InitSliceVec `
2827
2928` SliceVec ` and ` InitSliceVec ` are pretty similar, you give them a slice
3029buffer, and they store all of thier values in that buffer. But have three major
@@ -65,6 +64,8 @@ let mut slice_vec = InitSliceVec::new(&mut init_buffer);
6564slice_vec . push (0 );
6665```
6766
67+ #### ` TypeVec `
68+
6869` TypeVec ` is an owned buffer. You can use like so:
6970
7071``` rust
@@ -85,6 +86,41 @@ As a neat side-effect of this framework, you can also get an efficient
8586` GenericVec ` for zero-sized types, just a ` usize ` in size! This feature
8687can be on stable ` no_std ` .
8788
89+ #### ` ArrayVec ` and ` InitArrayVec `
90+
91+ ` ArrayVec ` and ` InitArrayVec `
92+ are just like the slice versions, but since they own their data,
93+ they can be freely moved around, unconstrained. You can also create
94+ a new ` ArrayVec ` without passing in an existing buffer,
95+ unlike the slice versions.
96+
97+ On stable, you can use the ` ArrayVec ` or
98+ ` InitArrayVec ` to construct the type. On ` nightly ` ,
99+ you can use the type aliases ` ArrayVec ` and
100+ ` InitArrayVec ` . The macros will be deprecated once
101+ ` min_const_generics ` hits stable.
102+
103+ The only limitation on stable is that you can only use ` InitArrayVec `
104+ capacity up to 32. i.e. ` InitArrayVec![i32; 33] ` doesn't work. ` ArrayVec ` does not suffer
105+ from this limitation because it is built atop ` TypeVec ` .
106+
107+ ``` rust
108+ use generic_vec :: ArrayVec ;
109+
110+ let mut array_vec = ArrayVec :: <i32 , 16 >:: new ();
111+
112+ array_vec . push (10 );
113+ array_vec . push (20 );
114+ array_vec . push (30 );
115+
116+ assert_eq! (array_vec , [10 , 20 , 30 ]);
117+ ```
118+
119+ The distinction between ` ArrayVec ` and ` InitArrayVec `
120+ is identical to their slice counterparts.
121+
122+ #### ` ZSVec `
123+
88124``` rust
89125use generic_vec :: ZSVec ;
90126
@@ -119,30 +155,18 @@ vec.try_push(5).expect_err("Tried to push past capacity!");
119155
120156### ` nightly `
121157
122- If you enable the nightly feature then you gain access to
123- ` ArrayVec ` and ` InitArrayVec ` . These are just like the
124- slice versions, but since they own their data, they can be
125- freely moved around, unconstrained. You can also create
126- a new ` ArrayVec ` without passing in an existing buffer.
127-
128- ``` rust
129- use generic_vec :: ArrayVec ;
130-
131- let mut array_vec = ArrayVec :: <i32 , 16 >:: new ();
132-
133- array_vec . push (10 );
134- array_vec . push (20 );
135- array_vec . push (30 );
136-
137- assert_eq! (array_vec , [10 , 20 , 30 ]);
138- ```
139-
140- The distinction between ` ArrayVec ` and ` InitArrayVec `
141- is identical to their slice counterparts.
158+ On ` nightly `
159+ * the restriction on ` InitArrayVec ` 's length goes away.
160+ * many functions/methods become ` const fn ` s
161+ * a number of optimizations are enabled
162+ * some diagnostics become better
142163
143164Note on the documentation: if the feature exists on ` Vec ` , then the documentation
144165is either exactly the same as ` Vec ` or slightly adapted to better fit ` GenericVec `
145166
167+ Note on implementation: large parts of the implementation came straight from ` Vec `
168+ so thanks for the amazing reference ` std ` !
169+
146170Current version: 0.1.1
147171
148172License: MIT/Apache-2.0
0 commit comments