summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-06-27 11:58:44 +0200
committermo8it <mo8it@proton.me>2024-06-27 11:58:44 +0200
commit091e1e7f7a1afad539479674e06cae7c8d8dab7f (patch)
treef458802a4457f5d27252bde62792018a25eda255 /exercises
parent92f249a52ca993d65db6ed70b85535c2f1720ec3 (diff)
traits2 solution
Diffstat (limited to 'exercises')
-rw-r--r--exercises/15_traits/traits2.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/exercises/15_traits/traits2.rs b/exercises/15_traits/traits2.rs
index 170779b..e904016 100644
--- a/exercises/15_traits/traits2.rs
+++ b/exercises/15_traits/traits2.rs
@@ -1,14 +1,9 @@
-// Your task is to implement the trait `AppendBar` for a vector of strings. To
-// implement this trait, consider for a moment what it means to 'append "Bar"'
-// to a vector of strings.
-//
-// No boiler plate code this time, you can do this!
-
trait AppendBar {
fn append_bar(self) -> Self;
}
-// TODO: Implement trait `AppendBar` for a vector of strings.
+// TODO: Implement the trait `AppendBar` for a vector of strings.
+// `appned_bar` should push the string "Bar" into the vector.
fn main() {
// You can optionally experiment here.
@@ -21,7 +16,7 @@ mod tests {
#[test]
fn is_vec_pop_eq_bar() {
let mut foo = vec![String::from("Foo")].append_bar();
- assert_eq!(foo.pop().unwrap(), String::from("Bar"));
- assert_eq!(foo.pop().unwrap(), String::from("Foo"));
+ assert_eq!(foo.pop().unwrap(), "Bar");
+ assert_eq!(foo.pop().unwrap(), "Foo");
}
}