1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*!
Crate for non-empty continuous collections.
Being continuous ends up being useful as this way converting between a type and its regular counterpart becomes a zero-cost operation.
All types utilise `#[repr(transparent)]`.
This crate attempts to reimplement as much functionality as possible from the non-empty counterparts. In many cases, they are drop-in replacements.
# Examples
```
let first_element = 10;
let mut non_empty_vec: NonEmptyVec<i32> = NonEmptyVec::new(first_element);
non_empty_vec.reserve(2);
non_empty_vec.push(20);
non_empty_vec.push(30);
_ = non_empty_vec.try_pop();
let non_empty_slice: &NonEmptySlice<i32> = &non_empty_vec[..=1];
let non_empty_slice_mut: &mut NonEmptySlice<i32> = &mut non_empty_vec[..];
let length: std::num::NonZeroUsize = non_empty_slice.len();
let non_empty_vec_from_macro = ne_vec![99, 98, 97];
```
Some operations allow for infalible operations with arrays whose length is checked not to be 0 at compile-time.
```
let arr = [1, 2, 3];
let mut non_empty_vec: NonEmptyVec<i32> = NonEmptyVec::from_arr(arr);
```
\
If the length of the array is not 0, a compiler error will be given. This requires a full build and does not show up when running `cargo check`.
```
let arr2 = [];
let mut non_empty_vec: NonEmptyVec<i32> = NonEmptyVec::from_arr(arr); // !!!
```
# Features
## `smallvec`
Exposes `NonEmptySmallVec`, a non-empty wrapper around `SmallVec` from the `small_vec` crate.
```
let first_element = 10;
let mut non_empty_small_vec: NonEmptySmallVec<[usize; 5]> = NonEmptySmallVec::new(first_element);
non_empty_small_vec.reserve(2);
non_empty_small_vec.push(20);
non_empty_small_vec.push(30);
let _: bool = non_empty_small_vec.spilled();
let non_empty_slice: &NonEmptySlice<i32> = &non_empty_small_vec[..=1];
let non_empty_slice_mut: &mut NonEmptySlice<i32> = &mut non_empty_small_vec[..];
let non_empty_smallvec_from_macro = ne_smallvec![99, 98, 97];
```
\
Smallvec can also has operations where the length of the array can be checked at compile-time.
```
let arr3 = [4, 5, 6];
let mut non_empty_small_vec: NonEmptySmallVec<i32> = NonEmptySmallVec::from_arr(arr3);
```
*/
pub use *;
pub use *;
pub use *;