Skip to content

Commit ffc76a4

Browse files
committed
update README
1 parent 135febe commit ffc76a4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,24 @@ assert_eq!(vec.len(), 3);
100100
assert_eq!(std::mem::size_of_val(&vec), std::mem::size_of::<usize>());
101101
```
102102

103-
### Nightly
103+
### `alloc`
104+
105+
A `HeapVec` is just `Vec`, but built atop `GenericVec`,
106+
meaning you get all the features of `GenericVec` for free! But this
107+
requries either the `alloc` or `std` feature to be enabled.
108+
109+
```rust
110+
use generic_vec::{HeapVec, gvec};
111+
let mut vec: HeapVec<u32> = gvec![1, 2, 3, 4];
112+
assert_eq!(vec.capacity(), 4);
113+
vec.extend(&[5, 6, 7, 8]);
114+
115+
assert_eq!(vec, [1, 2, 3, 4, 5, 6, 7, 8]);
116+
117+
vec.try_push(5).expect_err("Tried to push past capacity!");
118+
```
119+
120+
### `nightly`
104121

105122
If you enable the nightly feature then you gain access to
106123
`ArrayVec` and `InitArrayVec`. These are just like the
@@ -123,10 +140,6 @@ assert_eq!(array_vec, [10, 20, 30]);
123140
The distinction between `ArrayVec` and `InitArrayVec`
124141
is identical to their slice counterparts.
125142

126-
Finally a `HeapVec` is just `Vec`, but built atop `GenericVec`,
127-
meaning you get all the features of `GenericVec` for free! But this
128-
requries either the `alloc` or `std` feature to be enabled.
129-
130143
Note on the documentation: if the feature exists on `Vec`, then the documentation
131144
is either exactly the same as `Vec` or slightly adapted to better fit `GenericVec`
132145

0 commit comments

Comments
 (0)