summaryrefslogtreecommitdiff
path: root/solutions
diff options
context:
space:
mode:
Diffstat (limited to 'solutions')
-rw-r--r--solutions/03_if/if2.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/solutions/03_if/if2.rs b/solutions/03_if/if2.rs
index 4e18198..440bba0 100644
--- a/solutions/03_if/if2.rs
+++ b/solutions/03_if/if2.rs
@@ -1 +1,33 @@
-// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
+fn foo_if_fizz(fizzish: &str) -> &str {
+ if fizzish == "fizz" {
+ "foo"
+ } else if fizzish == "fuzz" {
+ "bar"
+ } else {
+ "baz"
+ }
+}
+
+fn main() {
+ // You can optionally experiment here.
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn foo_for_fizz() {
+ assert_eq!(foo_if_fizz("fizz"), "foo");
+ }
+
+ #[test]
+ fn bar_for_fuzz() {
+ assert_eq!(foo_if_fizz("fuzz"), "bar");
+ }
+
+ #[test]
+ fn default_to_baz() {
+ assert_eq!(foo_if_fizz("literally anything"), "baz");
+ }
+}