Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vec: add a "View" that can mutate the vec and erase the const generic. #425

Merged
merged 19 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
reitermarkus marked this conversation as resolved.
Show resolved Hide resolved
// 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};
sosthene-nitrokey marked this conversation as resolved.
Show resolved Hide resolved

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