Skip to content

Commit 9807e38

Browse files
committed
Format code using 'cargo fmt'
1 parent 5d34a1c commit 9807e38

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

examples/greet.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::mem;
33
use std::os::raw::{c_char, c_void};
44

55
#[no_mangle]
6-
pub extern fn allocate(size: usize) -> *mut c_void {
6+
pub extern "C" fn allocate(size: usize) -> *mut c_void {
77
let mut buffer = Vec::with_capacity(size);
88
let pointer = buffer.as_mut_ptr();
99
mem::forget(buffer);
@@ -12,14 +12,14 @@ pub extern fn allocate(size: usize) -> *mut c_void {
1212
}
1313

1414
#[no_mangle]
15-
pub extern fn deallocate(pointer: *mut c_void, capacity: usize) {
15+
pub extern "C" fn deallocate(pointer: *mut c_void, capacity: usize) {
1616
unsafe {
1717
let _ = Vec::from_raw_parts(pointer, 0, capacity);
1818
}
1919
}
2020

2121
#[no_mangle]
22-
pub extern fn greet(subject: *mut c_char) -> *mut c_char {
22+
pub extern "C" fn greet(subject: *mut c_char) -> *mut c_char {
2323
let subject = unsafe { CStr::from_ptr(subject).to_bytes().to_vec() };
2424
let mut output = b"Hello, ".to_vec();
2525
output.extend(&subject);

examples/memory.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#[no_mangle]
2-
pub extern fn return_hello() -> *const u8 {
2+
pub extern "C" fn return_hello() -> *const u8 {
33
b"Hello, World!\0".as_ptr()
44
}

examples/simple.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#[no_mangle]
2-
pub extern fn sum(x: i32, y: i32) -> i32 {
2+
pub extern "C" fn sum(x: i32, y: i32) -> i32 {
33
x + y
44
}

tests/tests.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
#[no_mangle]
2-
pub extern fn sum(x: i32, y: i32) -> i32 {
2+
pub extern "C" fn sum(x: i32, y: i32) -> i32 {
33
x + y
44
}
55

66
#[no_mangle]
7-
pub extern fn arity_0() -> i32 {
7+
pub extern "C" fn arity_0() -> i32 {
88
42
99
}
1010

1111
#[no_mangle]
12-
pub extern fn i32_i32(x: i32) -> i32 {
12+
pub extern "C" fn i32_i32(x: i32) -> i32 {
1313
x
1414
}
1515

1616
#[no_mangle]
17-
pub extern fn i64_i64(x: i64) -> i64 {
17+
pub extern "C" fn i64_i64(x: i64) -> i64 {
1818
x
1919
}
2020

2121
#[no_mangle]
22-
pub extern fn f32_f32(x: f32) -> f32 {
22+
pub extern "C" fn f32_f32(x: f32) -> f32 {
2323
x
2424
}
2525

2626
#[no_mangle]
27-
pub extern fn f64_f64(x: f64) -> f64 {
27+
pub extern "C" fn f64_f64(x: f64) -> f64 {
2828
x
2929
}
3030

3131
#[no_mangle]
32-
pub extern fn i32_i64_f32_f64_f64(a: i32, b: i64, c: f32, d: f64) -> f64 {
32+
pub extern "C" fn i32_i64_f32_f64_f64(a: i32, b: i64, c: f32, d: f64) -> f64 {
3333
a as f64 + b as f64 + c as f64 + d
3434
}
3535

3636
#[no_mangle]
37-
pub extern fn bool_casted_to_i32() -> bool {
37+
pub extern "C" fn bool_casted_to_i32() -> bool {
3838
true
3939
}
4040

4141
#[no_mangle]
42-
pub extern fn string() -> *const u8 {
42+
pub extern "C" fn string() -> *const u8 {
4343
b"Hello, World!\0".as_ptr()
4444
}
4545

4646
#[no_mangle]
47-
pub extern fn void() {}
47+
pub extern "C" fn void() {}

0 commit comments

Comments
 (0)