From ee0a8f2c893b19d091252122096aa460ceea3718 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 Jul 2024 22:14:57 +0800 Subject: [PATCH] rustlings 100 done --- exercises/tests/Cargo.lock | 7 +++++++ exercises/tests/Cargo.toml | 7 +++++++ exercises/tests/build.rs | 5 ++--- exercises/tests/tests7.rs | 1 - exercises/tests/tests8.rs | 1 - exercises/tests/tests9.rs | 4 ++-- 6 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 exercises/tests/Cargo.lock create mode 100644 exercises/tests/Cargo.toml diff --git a/exercises/tests/Cargo.lock b/exercises/tests/Cargo.lock new file mode 100644 index 00000000..7599e243 --- /dev/null +++ b/exercises/tests/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "tests7" +version = "0.0.1" diff --git a/exercises/tests/Cargo.toml b/exercises/tests/Cargo.toml new file mode 100644 index 00000000..025327f6 --- /dev/null +++ b/exercises/tests/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "tests7" +version = "0.0.1" +edition = "2021" +[[bin]] +name = "tests7" +path = "tests7.rs" \ No newline at end of file diff --git a/exercises/tests/build.rs b/exercises/tests/build.rs index aa518cef..3c4d060f 100644 --- a/exercises/tests/build.rs +++ b/exercises/tests/build.rs @@ -1,7 +1,6 @@ //! This is the build script for both tests7 and tests8. //! //! You should modify this file to make both exercises pass. - fn main() { // In tests7, we should set up an environment variable // called `TEST_FOO`. Print in the standard output to let @@ -11,7 +10,7 @@ fn main() { .unwrap() .as_secs(); // What's the use of this timestamp here? let your_command = format!( - "Your command here with {}, please checkout exercises/tests/build.rs", + "rustc-env=TEST_FOO=", timestamp ); println!("cargo:{}", your_command); @@ -19,6 +18,6 @@ fn main() { // In tests8, we should enable "pass" feature to make the // testcase return early. Fill in the command to tell // Cargo about that. - let your_command = "Your command here, please checkout exercises/tests/build.rs"; + let your_command = "rustc-cfg=pass"; println!("cargo:{}", your_command); } diff --git a/exercises/tests/tests7.rs b/exercises/tests/tests7.rs index 66b37b72..09574783 100644 --- a/exercises/tests/tests7.rs +++ b/exercises/tests/tests7.rs @@ -34,7 +34,6 @@ // Execute `rustlings hint tests7` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE fn main() {} diff --git a/exercises/tests/tests8.rs b/exercises/tests/tests8.rs index ce7e35d8..b9eb0fb1 100644 --- a/exercises/tests/tests8.rs +++ b/exercises/tests/tests8.rs @@ -7,7 +7,6 @@ // Execute `rustlings hint tests8` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE fn main() {} diff --git a/exercises/tests/tests9.rs b/exercises/tests/tests9.rs index ea2a8ec0..951aaa26 100644 --- a/exercises/tests/tests9.rs +++ b/exercises/tests/tests9.rs @@ -27,15 +27,15 @@ // // You should NOT modify any existing code except for adding two lines of attributes. -// I AM NOT DONE - extern "Rust" { fn my_demo_function(a: u32) -> u32; + #[link_name = "my_demo_function"] fn my_demo_function_alias(a: u32) -> u32; } mod Foo { // No `extern` equals `extern "Rust"`. + #[no_mangle] fn my_demo_function(a: u32) -> u32 { a }