Skip to content

Commit

Permalink
Replace .as_mut().unwrap() with &mut *.
Browse files Browse the repository at this point in the history
  • Loading branch information
veluca93 committed Aug 29, 2024
1 parent 8884f0e commit c62359f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub unsafe extern "C" fn RBrotliEncCompress(
// SAFETY: caller guarantees the pointer to be dereferenceable, that the pointer points to a
// valid encoder created with RBrotliEncMakeEncoder, and that the encoder will not be
// read or written through other pointers during the function call.
let encoder = unsafe { encoder.as_mut() }.unwrap();
let encoder = unsafe { &mut *encoder };
// SAFETY: caller guarantees `data` to point at `len` bytes of initialized memory.
let data = unsafe { slice_from_raw_parts(data, len).as_ref() };
let Some(data) = data else {
Expand Down Expand Up @@ -94,7 +94,7 @@ pub unsafe extern "C" fn RBrotliEncMaxRequiredSize(
// SAFETY: caller guarantees the pointer to be dereferenceable, that the pointer points to a
// valid encoder created with RBrotliEncMakeEncoder, and that the encoder will not be
// mutated during the call.
let encoder = unsafe { encoder.as_ref() }.unwrap();
let encoder = unsafe { &*encoder };
encoder.max_required_size(in_size)
}

Expand Down

0 comments on commit c62359f

Please sign in to comment.