|
14 | 14 | const_panic, |
15 | 15 | const_fn, |
16 | 16 | const_mut_refs, |
| 17 | + const_raw_ptr_deref, |
17 | 18 | ) |
18 | 19 | )] |
19 | 20 | #![cfg_attr(feature = "nightly", forbid(unsafe_op_in_unsafe_fn))] |
|
117 | 118 | //! assert_eq!(std::mem::size_of_val(&vec), std::mem::size_of::<usize>()); |
118 | 119 | //! ``` |
119 | 120 | //! |
120 | | -//! ## Nightly |
| 121 | +//! ## `alloc` |
| 122 | +//! |
| 123 | +//! A [`HeapVec`] is just [`Vec`], but built atop [`GenericVec`], |
| 124 | +//! meaning you get all the features of [`GenericVec`] for free! But this |
| 125 | +//! requries either the `alloc` or `std` feature to be enabled. |
| 126 | +//! |
| 127 | +//! ```rust |
| 128 | +//! use generic_vec::{HeapVec, gvec}; |
| 129 | +//! let mut vec: HeapVec<u32> = gvec![1, 2, 3, 4]; |
| 130 | +//! assert_eq!(vec.capacity(), 4); |
| 131 | +//! vec.extend(&[5, 6, 7, 8]); |
| 132 | +//! |
| 133 | +//! assert_eq!(vec, [1, 2, 3, 4, 5, 6, 7, 8]); |
| 134 | +//! |
| 135 | +//! vec.try_push(5).expect_err("Tried to push past capacity!"); |
| 136 | +//! ``` |
| 137 | +//! |
| 138 | +//! ## `nightly` |
121 | 139 | //! |
122 | 140 | //! If you enable the nightly feature then you gain access to |
123 | 141 | //! [`ArrayVec`] and [`InitArrayVec`]. These are just like the |
124 | 142 | //! slice versions, but since they own their data, they can be |
125 | 143 | //! freely moved around, unconstrained. You can also create |
126 | 144 | //! a new [`ArrayVec`] without passing in an existing buffer. |
127 | 145 | //! |
128 | | -//! ```rust,ignore |
| 146 | +//! ```rust |
| 147 | +//! # #![cfg_attr(not(feature = "nightly"), ignore)] |
129 | 148 | //! use generic_vec::ArrayVec; |
130 | 149 | //! |
131 | 150 | //! let mut array_vec = ArrayVec::<i32, 16>::new(); |
|
140 | 159 | //! The distinction between [`ArrayVec`] and [`InitArrayVec`] |
141 | 160 | //! is identical to their slice counterparts. |
142 | 161 | //! |
143 | | -//! Finally a [`HeapVec`] is just [`Vec`], but built atop [`GenericVec`], |
144 | | -//! meaning you get all the features of [`GenericVec`] for free! But this |
145 | | -//! requries either the `alloc` or `std` feature to be enabled. |
146 | | -//! |
147 | 162 | //! Note on the documentation: if the feature exists on [`Vec`], then the documentation |
148 | 163 | //! is either exactly the same as [`Vec`] or slightly adapted to better fit [`GenericVec`] |
149 | 164 |
|
@@ -409,6 +424,7 @@ impl<T, B, A> TypeVec<T, B, A> { |
409 | 424 | /// Create a new [`TypeVec`] with the given alignment type |
410 | 425 | pub const fn with_align() -> Self { |
411 | 426 | #[cfg(not(feature = "nightly"))] |
| 427 | + #[allow(clippy::no_effect)] |
412 | 428 | { |
413 | 429 | [()][(!<raw::UninitBuffer<B, A> as raw::Storage<T>>::IS_ALIGNED) as usize]; |
414 | 430 | } |
|
0 commit comments