File tree Expand file tree Collapse file tree 1 file changed +5
-14
lines changed
Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Original file line number Diff line number Diff line change 2727//
2828// You should NOT modify any existing code except for adding two lines of attributes.
2929
30- // I AM NOT DONE
31-
3230extern "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
3937mod 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}
You can’t perform that action at this time.
0 commit comments