Skip to content

Commit d37f9d0

Browse files
committed
v0.10.0
1 parent 3e0879e commit d37f9d0

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## Unreleased
3+
## 0.10.0
44
### Changed
55
- `AnyValue::bytes()->*const u8` and `AnyValue::size()->usize` replaced with
66
`AnyValue::as_bytes()->&[u8]`. Same for `AnyValueMut`.
@@ -10,8 +10,11 @@
1010

1111
### Added
1212
- `Debug` implemented for `AnyVec`, `AnyVecTyped`.
13-
- `AnyValueMut::swap()`.
14-
- `AnyVec`/`AnyVecTyped` `::set_len()`.
13+
- `AnyValueMut::swap()` added.
14+
- `AnyVec`/`AnyVecTyped` `::set_len()` added.
15+
- `AnyVec::as_bytes_mut` added.
16+
- `AnyVec::spare_bytes_mut` added.
17+
- `AnyVecTyped::spare_capacity_mut` added.
1518
- `mem::StackN` added.
1619

1720
### Fixed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "any_vec"
33
authors = ["Andrey Diduh <[email protected]>"]
44
license = "MIT OR Apache-2.0"
5-
version = "0.9.1"
5+
version = "0.10.0"
66
edition = "2021"
77
description = "Type erased vector. Most operations can be done without type knowledge. Mostly zero overhead."
88
repository = "https://github.com/tower120/any_vec"

src/any_vec_typed.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::fmt::{Debug, Formatter};
22
use std::marker::PhantomData;
3+
use std::mem::MaybeUninit;
34
use std::ops::{Range, RangeBounds};
45
use std::ptr::NonNull;
56
use std::slice;
@@ -243,7 +244,7 @@ impl<'a, T: 'static, M: MemBuilder + 'a> AnyVecTyped<'a, T, M>{
243244
unsafe{
244245
slice::from_raw_parts(
245246
self.as_ptr(),
246-
self.this().len,
247+
self.len(),
247248
)
248249
}
249250
}
@@ -253,7 +254,17 @@ impl<'a, T: 'static, M: MemBuilder + 'a> AnyVecTyped<'a, T, M>{
253254
unsafe{
254255
slice::from_raw_parts_mut(
255256
self.as_mut_ptr(),
256-
self.this().len,
257+
self.len(),
258+
)
259+
}
260+
}
261+
262+
#[inline]
263+
pub fn spare_capacity_mut(&mut self) -> &'a mut[MaybeUninit<T>] {
264+
unsafe {
265+
slice::from_raw_parts_mut(
266+
self.as_mut_ptr().add(self.len()) as *mut MaybeUninit<T>,
267+
self.capacity() - self.len(),
257268
)
258269
}
259270
}

0 commit comments

Comments
 (0)