Skip to content

Shrink unsafe block for the VectorWriter impl #107

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions atom/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ impl<'a, 'b, A: ScalarAtom> VectorWriter<'a, 'b, A> {
};
self.frame
.allocate(raw_data.len(), false)
.map(|(_, space)| unsafe {
.map(|(_, space)| {
space.copy_from_slice(raw_data);
std::slice::from_raw_parts_mut(
unsafe { std::slice::from_raw_parts_mut(
space.as_mut_ptr() as *mut A::InternalType,
data.len(),
)
) }
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions urid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@ impl Unmap for HashURIDMapper {
// This is safe because the only way this reference might become invalid is if an
// entry gets overwritten, which is not something that we allow through this
// interface.
return Some(unsafe {
return Some({
let bytes = uri.as_bytes_with_nul();
Uri::from_bytes_with_nul_unchecked(std::slice::from_raw_parts(
unsafe { Uri::from_bytes_with_nul_unchecked(std::slice::from_raw_parts(
bytes.as_ptr(),
bytes.len(),
))
)) }
});
}
}
Expand Down