Skip to content

Commit afbab0f

Browse files
committed
Cargo fmt
1 parent 46d6d29 commit afbab0f

File tree

8 files changed

+302
-773
lines changed

8 files changed

+302
-773
lines changed

csbindgen-tests/src/counter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[repr(C)]
22
pub struct Args {
3-
pub init: u32,
4-
pub by: u32,
3+
pub init: u32,
4+
pub by: u32,
55
}
66

77
#[repr(C)]
@@ -12,7 +12,7 @@ pub struct Counter {
1212

1313
impl Counter {
1414
pub fn new(args: Args) -> Counter {
15-
Counter{
15+
Counter {
1616
val: args.init,
1717
by: args.by,
1818
}
@@ -31,4 +31,4 @@ impl Counter {
3131
self.val -= self.by;
3232
self.val
3333
}
34-
}
34+
}

csbindgen-tests/src/lib.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#![allow(clippy::missing_safety_doc)]
22

33
use std::{
4-
collections::HashSet, ffi::{c_char, c_long, c_ulong, CString}, mem::transmute, num::*, ptr::NonNull
4+
collections::HashSet,
5+
ffi::{c_char, c_long, c_ulong, CString},
6+
mem::transmute,
7+
num::*,
8+
ptr::NonNull,
59
};
610

711
mod counter;
@@ -398,7 +402,9 @@ pub extern "C" fn alloc_c_string() -> *mut c_char {
398402

399403
#[no_mangle]
400404
pub unsafe extern "C" fn free_c_string(str: *mut c_char) {
401-
unsafe { let _ = CString::from_raw(str); };
405+
unsafe {
406+
let _ = CString::from_raw(str);
407+
};
402408
}
403409

404410
#[no_mangle]
@@ -451,7 +457,9 @@ pub extern "C" fn create_context() -> *mut Context {
451457

452458
#[no_mangle]
453459
pub unsafe extern "C" fn delete_context(context: *mut Context) {
454-
unsafe { let _ = Box::from_raw(context); };
460+
unsafe {
461+
let _ = Box::from_raw(context);
462+
};
455463
}
456464

457465
#[no_mangle]
@@ -644,7 +652,7 @@ pub struct InternalHiddenContext {
644652
}
645653

646654
pub struct TreatAsEmptyStruct {
647-
_internal: std::sync::Arc<InternalHiddenContext>
655+
_internal: std::sync::Arc<InternalHiddenContext>,
648656
}
649657

650658
#[no_mangle]
@@ -690,7 +698,6 @@ pub extern "C" fn set_callback(alloc_callback: MyCallback) {
690698
println!("Your callback is {alloc_callback:p}");
691699
}
692700

693-
694701
#[no_mangle]
695702
pub extern "C" fn callback_test10(cb: extern "C" fn(a: i32) -> i32) -> i32 {
696703
cb(100)
@@ -700,12 +707,12 @@ use counter::Args;
700707
use counter::Counter;
701708

702709
#[no_mangle]
703-
pub extern fn counterCreate(args: Args) -> *mut Counter {
710+
pub extern "C" fn counterCreate(args: Args) -> *mut Counter {
704711
unsafe { transmute::<Box<_>, *mut _>(Box::new(Counter::new(args))) }
705712
}
706713

707714
#[no_mangle]
708-
pub unsafe extern fn counterGetValue(ptr: *mut Counter) -> u32 {
715+
pub unsafe extern "C" fn counterGetValue(ptr: *mut Counter) -> u32 {
709716
let mut _counter = unsafe { &mut *ptr };
710717
_counter.get()
711718
}
@@ -719,4 +726,4 @@ pub enum CResultStatus {
719726
#[no_mangle]
720727
pub extern "C" fn enum_test2(status: CResultStatus) -> i32 {
721728
status as i32
722-
}
729+
}

0 commit comments

Comments
 (0)