Skip to content

Instantly share code, notes, and snippets.

@mfpiccolo
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfpiccolo/0c0bcc036d9af1fddc4b to your computer and use it in GitHub Desktop.
Save mfpiccolo/0c0bcc036d9af1fddc4b to your computer and use it in GitHub Desktop.
pub struct TwoNumbers {
first: i32,
second: i32,
}
#[no_mangle]
pub extern fn add_struct_vals(numbers: TwoNumbers) -> i32 {
numbers.first + numbers.second
}
#[test]
fn it_works() {
let numbers = TwoNumbers { first: 10, second: 20 };
assert!(add_struct_vals(numbers) == 30);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment