Skip to content

Commit

Permalink
make DeviceSlice a newtype around [()]
Browse files Browse the repository at this point in the history
  • Loading branch information
beepster4096 committed Feb 14, 2022
1 parent 99ace7a commit 481e807
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 86 deletions.
4 changes: 2 additions & 2 deletions crates/cust/src/memory/device/device_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,13 @@ impl<T: DeviceCopy> Deref for DeviceBuffer<T> {
type Target = DeviceSlice<T>;

fn deref(&self) -> &DeviceSlice<T> {
unsafe { &*(self as *const _ as *const DeviceSlice<T>) }
unsafe { DeviceSlice::from_raw_parts(self.buf, self.len) }
}
}

impl<T: DeviceCopy> DerefMut for DeviceBuffer<T> {
fn deref_mut(&mut self) -> &mut DeviceSlice<T> {
unsafe { &mut *(self as *mut _ as *mut DeviceSlice<T>) }
unsafe { DeviceSlice::from_raw_parts_mut(self.buf, self.len) }
}
}

Expand Down
Loading

0 comments on commit 481e807

Please sign in to comment.