Skip to content

Commit c593fa5

Browse files
authored
Merge pull request #425 from Nitrokey/vec-dyn-alias
Vec: add a "View" that can mutate the vec and erase the const generic.
2 parents edadef8 + cdfe308 commit c593fa5

File tree

4 files changed

+1053
-224
lines changed

4 files changed

+1053
-224
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1616
- Added `Vec::spare_capacity_mut`.
1717
- Added `Extend` impls for `Deque`.
1818
- Added `Deque::make_contiguous`.
19+
- Added `VecView`, the `!Sized` version of `Vec`.
1920

2021
### Changed
2122

cfail/ui/not-send.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ error[E0277]: `*const ()` cannot be sent between threads safely
7272
22 | is_send::<Vec<NotSend, 4>>();
7373
| ^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
7474
|
75-
= help: within `heapless::Vec<PhantomData<*const ()>, 4>`, the trait `Send` is not implemented for `*const ()`
75+
= help: within `heapless::vec::VecInner<[MaybeUninit<PhantomData<*const ()>>; 4]>`, the trait `Send` is not implemented for `*const ()`
7676
note: required because it appears within the type `PhantomData<*const ()>`
7777
--> $RUST/core/src/marker.rs
7878
note: required because it appears within the type `ManuallyDrop<PhantomData<*const ()>>`
7979
--> $RUST/core/src/mem/manually_drop.rs
8080
note: required because it appears within the type `MaybeUninit<PhantomData<*const ()>>`
8181
--> $RUST/core/src/mem/maybe_uninit.rs
8282
= note: required because it appears within the type `[MaybeUninit<PhantomData<*const ()>>; 4]`
83-
note: required because it appears within the type `Vec<PhantomData<*const ()>, 4>`
83+
note: required because it appears within the type `VecInner<[MaybeUninit<PhantomData<*const ()>>; 4]>`
8484
--> $HEAPLESS/src/vec.rs
8585
|
86-
| pub struct Vec<T, const N: usize> {
87-
| ^^^
86+
| pub struct VecInner<B: ?Sized + VecDrop> {
87+
| ^^^^^^^^
8888
note: required by a bound in `is_send`
8989
--> ui/not-send.rs:14:8
9090
|

src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,14 @@ pub use indexmap::{
8888
pub use indexset::{FnvIndexSet, IndexSet, Iter as IndexSetIter};
8989
pub use linear_map::LinearMap;
9090
pub use string::String;
91-
pub use vec::Vec;
91+
92+
// Workaround https://github.com/rust-lang/rust/issues/119015. This is required so that the methods on `VecView` and `Vec` are properly documented.
93+
// cfg(doc) prevents `VecInner` being part of the public API.
94+
// doc(hidden) prevents the `pub use vec::VecInner` from being visible in the documentation.
95+
#[cfg(doc)]
96+
#[doc(hidden)]
97+
pub use vec::VecInner as _;
98+
pub use vec::{Vec, VecView};
9299

93100
#[macro_use]
94101
#[cfg(test)]

0 commit comments

Comments
 (0)