diff --git a/config.json b/config.json index 6fe175386..ddd2d106a 100644 --- a/config.json +++ b/config.json @@ -8,7 +8,6 @@ "slug": "hello-world", "difficulty": 1, "topics": [ - "Some/None", "println!" ] }, diff --git a/exercises/hello-world/example.rs b/exercises/hello-world/example.rs index 0b61c769f..2709b7b3d 100644 --- a/exercises/hello-world/example.rs +++ b/exercises/hello-world/example.rs @@ -1,6 +1,3 @@ -pub fn hello(name: Option<&str>) -> String { - match name { - Some(n) => format!("Hello, {}!", n), - None => "Hello, World!".to_string(), - } +pub fn hello() -> &'static str { + "Hello, World!" } diff --git a/exercises/hello-world/src/lib.rs b/exercises/hello-world/src/lib.rs new file mode 100644 index 000000000..f147ab7b6 --- /dev/null +++ b/exercises/hello-world/src/lib.rs @@ -0,0 +1,5 @@ +// The &'static here means the return type has a static lifetime. +// This is a Rust feature that you don't need to worry about now. +pub fn hello() -> &'static str { + "Goodbye, World!" +} diff --git a/exercises/hello-world/tests/hello-world.rs b/exercises/hello-world/tests/hello-world.rs index b8be861b7..99a3c1561 100644 --- a/exercises/hello-world/tests/hello-world.rs +++ b/exercises/hello-world/tests/hello-world.rs @@ -1,18 +1,6 @@ extern crate hello_world; #[test] -fn test_no_name() { - assert_eq!("Hello, World!", hello_world::hello(None)); -} - -#[test] -#[ignore] -fn test_sample_name() { - assert_eq!("Hello, Alice!", hello_world::hello(Some("Alice"))); -} - -#[test] -#[ignore] -fn test_other_same_name() { - assert_eq!("Hello, Bob!", hello_world::hello(Some("Bob"))); +fn test_hello_world() { + assert_eq!("Hello, World!", hello_world::hello()); }