clippy fixes

This commit is contained in:
George Thomas 2026-03-25 15:08:45 +00:00
parent 7d9982112a
commit a06f3076c7

View File

@ -11,7 +11,7 @@ fn say_hello(name: &str) {
}
#[unsafe(no_mangle)]
extern "C" fn hello(c: *const c_char) -> () {
extern "C" fn hello(c: *const c_char) {
say_hello(unsafe { CStr::from_ptr(c) }.to_str().unwrap())
}
@ -23,7 +23,7 @@ struct T {
}
#[unsafe(no_mangle)]
extern "C" fn hello_struct(t: &T) -> () {
extern "C" fn hello_struct(t: &T) {
say_hello(&format!("{:?}", t))
}
@ -35,7 +35,7 @@ enum Shape {
}
#[unsafe(no_mangle)]
extern "C" fn hello_shape(s: &Shape) -> () {
extern "C" fn hello_shape(s: &Shape) {
say_hello(&format!("{:?}", s))
}
@ -80,7 +80,7 @@ enum BTreeC {
#[unsafe(no_mangle)]
extern "C" fn sum_tree(t: &BTreeC) -> i64 {
(unsafe { std::mem::transmute::<_, &BTree<i64>>(t) }).sum()
(unsafe { std::mem::transmute::<&BTreeC, &BTree<i64>>(t) }).sum()
}
#[unsafe(no_mangle)]
@ -89,9 +89,6 @@ extern "C" fn sum_slice(v: *const i64, s: usize) -> i64 {
}
#[unsafe(no_mangle)]
extern "C" fn print_optional(x: Option<&i8>) -> () {
match x {
Some(x) => println!("{}", x / 2),
None => {}
}
extern "C" fn print_optional(x: Option<&i8>) {
if let Some(x) = x { println!("{}", x / 2) }
}