clippy fixes
This commit is contained in:
parent
7d9982112a
commit
a06f3076c7
15
rust/lib.rs
15
rust/lib.rs
@ -11,7 +11,7 @@ fn say_hello(name: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[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())
|
say_hello(unsafe { CStr::from_ptr(c) }.to_str().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ struct T {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
extern "C" fn hello_struct(t: &T) -> () {
|
extern "C" fn hello_struct(t: &T) {
|
||||||
say_hello(&format!("{:?}", t))
|
say_hello(&format!("{:?}", t))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ enum Shape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
extern "C" fn hello_shape(s: &Shape) -> () {
|
extern "C" fn hello_shape(s: &Shape) {
|
||||||
say_hello(&format!("{:?}", s))
|
say_hello(&format!("{:?}", s))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ enum BTreeC {
|
|||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
extern "C" fn sum_tree(t: &BTreeC) -> i64 {
|
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)]
|
#[unsafe(no_mangle)]
|
||||||
@ -89,9 +89,6 @@ extern "C" fn sum_slice(v: *const i64, s: usize) -> i64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
extern "C" fn print_optional(x: Option<&i8>) -> () {
|
extern "C" fn print_optional(x: Option<&i8>) {
|
||||||
match x {
|
if let Some(x) = x { println!("{}", x / 2) }
|
||||||
Some(x) => println!("{}", x / 2),
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user