cargo fmt

This commit is contained in:
Vinzenz Schroeter 2025-04-11 22:00:01 +02:00
commit 52f6f3f3fe
9 changed files with 149 additions and 102 deletions

View file

@ -71,9 +71,9 @@ pub unsafe extern "C" fn sp_cp437_grid_load(
data_length: usize,
) -> *mut SPCp437Grid {
assert!(data.is_null());
let data = unsafe{std::slice::from_raw_parts(data, data_length)};
let grid = servicepoint::Cp437Grid::load( width, height, data, );
if let Some(grid ) = grid {
let data = unsafe { std::slice::from_raw_parts(data, data_length) };
let grid = servicepoint::Cp437Grid::load(width, height, data);
if let Some(grid) = grid {
Box::leak(Box::new(SPCp437Grid(grid)))
} else {
std::ptr::null_mut()
@ -101,7 +101,7 @@ pub unsafe extern "C" fn sp_cp437_grid_clone(
cp437_grid: *const SPCp437Grid,
) -> NonNull<SPCp437Grid> {
assert!(!cp437_grid.is_null());
let result = Box::new(unsafe {(*cp437_grid).clone()});
let result = Box::new(unsafe { (*cp437_grid).clone() });
NonNull::from(Box::leak(result))
}
@ -123,7 +123,7 @@ pub unsafe extern "C" fn sp_cp437_grid_clone(
#[no_mangle]
pub unsafe extern "C" fn sp_cp437_grid_free(cp437_grid: *mut SPCp437Grid) {
assert!(!cp437_grid.is_null());
_ = unsafe {Box::from_raw(cp437_grid)};
_ = unsafe { Box::from_raw(cp437_grid) };
}
/// Gets the current value at the specified position.
@ -151,7 +151,7 @@ pub unsafe extern "C" fn sp_cp437_grid_get(
y: usize,
) -> u8 {
assert!(!cp437_grid.is_null());
unsafe{(*cp437_grid).0.get(x, y)}
unsafe { (*cp437_grid).0.get(x, y) }
}
/// Sets the value of the specified position in the [SPCp437Grid].
@ -185,7 +185,7 @@ pub unsafe extern "C" fn sp_cp437_grid_set(
value: u8,
) {
assert!(!cp437_grid.is_null());
unsafe {(*cp437_grid).0.set(x, y, value)};
unsafe { (*cp437_grid).0.set(x, y, value) };
}
/// Sets the value of all cells in the [SPCp437Grid].
@ -211,7 +211,7 @@ pub unsafe extern "C" fn sp_cp437_grid_fill(
value: u8,
) {
assert!(!cp437_grid.is_null());
unsafe {(*cp437_grid).0.fill(value)};
unsafe { (*cp437_grid).0.fill(value) };
}
/// Gets the width of the [SPCp437Grid] instance.
@ -234,7 +234,7 @@ pub unsafe extern "C" fn sp_cp437_grid_width(
cp437_grid: *const SPCp437Grid,
) -> usize {
assert!(!cp437_grid.is_null());
unsafe {(*cp437_grid).0.width()}
unsafe { (*cp437_grid).0.width() }
}
/// Gets the height of the [SPCp437Grid] instance.
@ -257,7 +257,7 @@ pub unsafe extern "C" fn sp_cp437_grid_height(
cp437_grid: *const SPCp437Grid,
) -> usize {
assert!(!cp437_grid.is_null());
unsafe {(*cp437_grid).0.height()}
unsafe { (*cp437_grid).0.height() }
}
/// Gets an unsafe reference to the data of the [SPCp437Grid] instance.
@ -279,7 +279,7 @@ pub unsafe extern "C" fn sp_cp437_grid_height(
pub unsafe extern "C" fn sp_cp437_grid_unsafe_data_ref(
cp437_grid: *mut SPCp437Grid,
) -> SPByteSlice {
let data = unsafe {(*cp437_grid).0.data_ref_mut()};
let data = unsafe { (*cp437_grid).0.data_ref_mut() };
SPByteSlice {
start: NonNull::new(data.as_mut_ptr_range().start).unwrap(),
length: data.len(),