1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
pub struct Foo { a: i32, b: i64, c: u8, d: i64 } impl Foo { pub fn new() -> Foo { Foo { a: 1, b: 2, c: 3, d: 4 } } } #[no_mangle] pub extern "C" fn new_foo() -> *mut Foo { let foo = Box::new(Foo::new()); Box::into_raw(foo) }