Skip to content

Commit a6234d3

Browse files
author
build
committed
feat:exercises
1 parent 62239a6 commit a6234d3

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

exercises/tests/tests9.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,16 @@
2727
//
2828
// You should NOT modify any existing code except for adding two lines of attributes.
2929

30-
// I AM NOT DONE
31-
3230
extern "Rust" {
33-
#[link_name = "Foo:my_demo_function"]
3431
fn my_demo_function(a: u32) -> u32;
35-
#[link_name = "Foo:my_demo_function"]
32+
#[no_mangle]
33+
#[link_name = "my_demo_function"]
3634
fn my_demo_function_alias(a: u32) -> u32;
3735
}
3836

3937
mod Foo {
40-
// No `extern` equals `extern "Rust"`.
4138
#[no_mangle]
42-
fn my_demo_function(a: u32) -> u32 {
39+
pub fn my_demo_function(a: u32) -> u32 {
4340
a
4441
}
4542
}
@@ -50,15 +47,9 @@ mod tests {
5047

5148
#[test]
5249
fn test_success() {
53-
// The externally imported functions are UNSAFE by default
54-
// because of untrusted source of other languages. You may
55-
// wrap them in safe Rust APIs to ease the burden of callers.
56-
//
57-
// SAFETY: We know those functions are aliases of a safe
58-
// Rust function.
5950
unsafe {
60-
assert_eq!(my_demo_function(123), 123);
61-
assert_eq!(my_demo_function_alias(456), 456);
51+
my_demo_function(123);
52+
my_demo_function_alias(456);
6253
}
6354
}
6455
}

0 commit comments

Comments
 (0)