Skip to content

Commit

Permalink
Remove needless unsafe from Buffer::from_{data,iter} (vulkano-rs#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0246 authored and hakolao committed Feb 20, 2024
1 parent 47d74cf commit 7ae66c9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions vulkano/src/buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ use std::{
hash::{Hash, Hasher},
mem::size_of_val,
ops::Range,
ptr,
sync::Arc,
};

Expand Down Expand Up @@ -280,7 +279,7 @@ impl Buffer {
{
let buffer = Buffer::new_sized(allocator, buffer_info, allocation_info)?;

unsafe { ptr::write(&mut *buffer.write()?, data) };
*buffer.write()? = data;

Ok(buffer)
}
Expand Down Expand Up @@ -317,7 +316,7 @@ impl Buffer {
)?;

for (o, i) in buffer.write()?.iter_mut().zip(iter) {
unsafe { ptr::write(o, i) };
*o = i;
}

Ok(buffer)
Expand Down

0 comments on commit 7ae66c9

Please # to comment.