Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

updates uses of Unique #20

Merged
merged 1 commit into from
May 2, 2020
Merged
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
6 changes: 3 additions & 3 deletions src/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
pub const fn new_in(alloc: A) -> Self {
// `cap: 0` means "unallocated". zero-sized types are ignored.
Self {
ptr: Unique::empty(),
ptr: Unique::dangling(),
cap: 0,
alloc,
}
Expand Down Expand Up @@ -182,7 +182,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
.alloc(layout, init)
.map_err(|_| AllocError { layout })?;
Ok(Self {
ptr: memory.ptr.cast().into(),
ptr: Unique::new(memory.ptr.cast().as_ptr()).unwrap(),
cap: Self::capacity_from_bytes(memory.size),
alloc,
})
Expand Down Expand Up @@ -541,7 +541,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
}

fn set_memory(&mut self, memory: MemoryBlock) {
self.ptr = memory.ptr.cast().into();
self.ptr = Unique::new(memory.ptr.cast().as_ptr()).unwrap();
self.cap = Self::capacity_from_bytes(memory.size);
}

Expand Down