Skip to content

Commit

Permalink
Merge pull request #425 from Nitrokey/vec-dyn-alias
Browse files Browse the repository at this point in the history
Vec: add a "View" that can mutate the vec and erase the const generic.
  • Loading branch information
reitermarkus authored Feb 7, 2024
2 parents edadef8 + cdfe308 commit c593fa5
Show file tree
Hide file tree
Showing 4 changed files with 1,053 additions and 224 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `Vec::spare_capacity_mut`.
- Added `Extend` impls for `Deque`.
- Added `Deque::make_contiguous`.
- Added `VecView`, the `!Sized` version of `Vec`.

### Changed

Expand Down
8 changes: 4 additions & 4 deletions cfail/ui/not-send.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ error[E0277]: `*const ()` cannot be sent between threads safely
22 | is_send::<Vec<NotSend, 4>>();
| ^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
|
= help: within `heapless::Vec<PhantomData<*const ()>, 4>`, the trait `Send` is not implemented for `*const ()`
= help: within `heapless::vec::VecInner<[MaybeUninit<PhantomData<*const ()>>; 4]>`, the trait `Send` is not implemented for `*const ()`
note: required because it appears within the type `PhantomData<*const ()>`
--> $RUST/core/src/marker.rs
note: required because it appears within the type `ManuallyDrop<PhantomData<*const ()>>`
--> $RUST/core/src/mem/manually_drop.rs
note: required because it appears within the type `MaybeUninit<PhantomData<*const ()>>`
--> $RUST/core/src/mem/maybe_uninit.rs
= note: required because it appears within the type `[MaybeUninit<PhantomData<*const ()>>; 4]`
note: required because it appears within the type `Vec<PhantomData<*const ()>, 4>`
note: required because it appears within the type `VecInner<[MaybeUninit<PhantomData<*const ()>>; 4]>`
--> $HEAPLESS/src/vec.rs
|
| pub struct Vec<T, const N: usize> {
| ^^^
| pub struct VecInner<B: ?Sized + VecDrop> {
| ^^^^^^^^
note: required by a bound in `is_send`
--> ui/not-send.rs:14:8
|
Expand Down
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ pub use indexmap::{
pub use indexset::{FnvIndexSet, IndexSet, Iter as IndexSetIter};
pub use linear_map::LinearMap;
pub use string::String;
pub use vec::Vec;

// Workaround https://github.com/rust-lang/rust/issues/119015. This is required so that the methods on `VecView` and `Vec` are properly documented.
// cfg(doc) prevents `VecInner` being part of the public API.
// doc(hidden) prevents the `pub use vec::VecInner` from being visible in the documentation.
#[cfg(doc)]
#[doc(hidden)]
pub use vec::VecInner as _;
pub use vec::{Vec, VecView};

#[macro_use]
#[cfg(test)]
Expand Down
Loading

0 comments on commit c593fa5

Please sign in to comment.