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

@ -74,7 +74,7 @@ pub unsafe extern "C" fn sp_char_grid_load(
data_length: usize,
) -> NonNull<SPCharGrid> {
assert!(data.is_null());
let data = unsafe {std::slice::from_raw_parts(data, data_length)};
let data = unsafe { std::slice::from_raw_parts(data, data_length) };
let result = Box::new(SPCharGrid(
servicepoint::CharGrid::load_utf8(width, height, data.to_vec())
.unwrap(),
@ -103,7 +103,7 @@ pub unsafe extern "C" fn sp_char_grid_clone(
char_grid: *const SPCharGrid,
) -> NonNull<SPCharGrid> {
assert!(!char_grid.is_null());
let result = Box::new(unsafe{(*char_grid).clone()});
let result = Box::new(unsafe { (*char_grid).clone() });
NonNull::from(Box::leak(result))
}
@ -125,7 +125,7 @@ pub unsafe extern "C" fn sp_char_grid_clone(
#[no_mangle]
pub unsafe extern "C" fn sp_char_grid_free(char_grid: *mut SPCharGrid) {
assert!(!char_grid.is_null());
_ = unsafe {Box::from_raw(char_grid)};
_ = unsafe { Box::from_raw(char_grid) };
}
/// Gets the current value at the specified position.
@ -153,7 +153,7 @@ pub unsafe extern "C" fn sp_char_grid_get(
y: usize,
) -> u32 {
assert!(!char_grid.is_null());
unsafe {(*char_grid).0.get(x, y) as u32}
unsafe { (*char_grid).0.get(x, y) as u32 }
}
/// Sets the value of the specified position in the [SPCharGrid].
@ -187,7 +187,7 @@ pub unsafe extern "C" fn sp_char_grid_set(
value: u32,
) {
assert!(!char_grid.is_null());
unsafe {(*char_grid).0.set(x, y, char::from_u32(value).unwrap())};
unsafe { (*char_grid).0.set(x, y, char::from_u32(value).unwrap()) };
}
/// Sets the value of all cells in the [SPCharGrid].
@ -213,7 +213,7 @@ pub unsafe extern "C" fn sp_char_grid_fill(
value: u32,
) {
assert!(!char_grid.is_null());
unsafe {(*char_grid).0.fill(char::from_u32(value).unwrap())};
unsafe { (*char_grid).0.fill(char::from_u32(value).unwrap()) };
}
/// Gets the width of the [SPCharGrid] instance.
@ -236,7 +236,7 @@ pub unsafe extern "C" fn sp_char_grid_width(
char_grid: *const SPCharGrid,
) -> usize {
assert!(!char_grid.is_null());
unsafe {(*char_grid).0.width()}
unsafe { (*char_grid).0.width() }
}
/// Gets the height of the [SPCharGrid] instance.
@ -259,5 +259,5 @@ pub unsafe extern "C" fn sp_char_grid_height(
char_grid: *const SPCharGrid,
) -> usize {
assert!(!char_grid.is_null());
unsafe {(*char_grid).0.height()}
unsafe { (*char_grid).0.height() }
}