Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code using 'cargo fmt' #26

Merged
merged 1 commit into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/greet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::mem;
use std::os::raw::{c_char, c_void};

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

#[no_mangle]
pub extern fn deallocate(pointer: *mut c_void, capacity: usize) {
pub extern "C" fn deallocate(pointer: *mut c_void, capacity: usize) {
unsafe {
let _ = Vec::from_raw_parts(pointer, 0, capacity);
}
}

#[no_mangle]
pub extern fn greet(subject: *mut c_char) -> *mut c_char {
pub extern "C" fn greet(subject: *mut c_char) -> *mut c_char {
let subject = unsafe { CStr::from_ptr(subject).to_bytes().to_vec() };
let mut output = b"Hello, ".to_vec();
output.extend(&subject);
Expand Down
2 changes: 1 addition & 1 deletion examples/memory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[no_mangle]
pub extern fn return_hello() -> *const u8 {
pub extern "C" fn return_hello() -> *const u8 {
b"Hello, World!\0".as_ptr()
}
2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[no_mangle]
pub extern fn sum(x: i32, y: i32) -> i32 {
pub extern "C" fn sum(x: i32, y: i32) -> i32 {
x + y
}
20 changes: 10 additions & 10 deletions tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
#[no_mangle]
pub extern fn sum(x: i32, y: i32) -> i32 {
pub extern "C" fn sum(x: i32, y: i32) -> i32 {
x + y
}

#[no_mangle]
pub extern fn arity_0() -> i32 {
pub extern "C" fn arity_0() -> i32 {
42
}

#[no_mangle]
pub extern fn i32_i32(x: i32) -> i32 {
pub extern "C" fn i32_i32(x: i32) -> i32 {
x
}

#[no_mangle]
pub extern fn i64_i64(x: i64) -> i64 {
pub extern "C" fn i64_i64(x: i64) -> i64 {
x
}

#[no_mangle]
pub extern fn f32_f32(x: f32) -> f32 {
pub extern "C" fn f32_f32(x: f32) -> f32 {
x
}

#[no_mangle]
pub extern fn f64_f64(x: f64) -> f64 {
pub extern "C" fn f64_f64(x: f64) -> f64 {
x
}

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

#[no_mangle]
pub extern fn bool_casted_to_i32() -> bool {
pub extern "C" fn bool_casted_to_i32() -> bool {
true
}

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

#[no_mangle]
pub extern fn void() {}
pub extern "C" fn void() {}