mirror of
https://github.com/notohh/rustlings.git
synced 2025-09-04 23:11:47 -04:00
if2 solution
This commit is contained in:
parent
7cdf6b7942
commit
eafb157d60
3 changed files with 41 additions and 7 deletions
exercises/03_if
|
@ -1,6 +1,4 @@
|
|||
// Step 1: Make me compile!
|
||||
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
|
||||
|
||||
// TODO: Fix the compiler error on this function.
|
||||
fn foo_if_fizz(fizzish: &str) -> &str {
|
||||
if fizzish == "fizz" {
|
||||
"foo"
|
||||
|
@ -13,13 +11,15 @@ fn main() {
|
|||
// You can optionally experiment here.
|
||||
}
|
||||
|
||||
// No test changes needed!
|
||||
// TODO: Read the tests to understand the desired behavior.
|
||||
// Make all tests pass without changing them.
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn foo_for_fizz() {
|
||||
// This means that calling `foo_if_fizz` with the argument "fizz" should return "foo".
|
||||
assert_eq!(foo_if_fizz("fizz"), "foo");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue