safe attr

This commit is contained in:
nora 2023-02-16 19:05:53 +01:00
parent 5f98cb10bc
commit 0cf263257c
5 changed files with 209 additions and 44 deletions

18
tests/safe_extern.rs Normal file
View file

@ -0,0 +1,18 @@
use uwu::safe_extern::safe_extern;
#[safe_extern]
extern "Rust" {
fn add(a: u8, b: u8) -> u8;
}
mod _impl {
#[no_mangle]
pub(super) fn add(a: u8, b: u8) -> u8 {
a + b
}
}
#[test]
fn adding() {
assert_eq!(add(1, 2), 3);
}