diff --git a/exercises/traits/traits1.rs b/exercises/traits/traits1.rs index 8253ef80..4cef7cd2 100644 --- a/exercises/traits/traits1.rs +++ b/exercises/traits/traits1.rs @@ -8,14 +8,14 @@ // which appends "Bar" to any object // implementing this trait. -// I AM NOT DONE trait AppendBar { fn append_bar(self) -> Self; } impl AppendBar for String { - //Add your code here - + fn append_bar(self) -> Self { + self + "Bar" + } } fn main() { diff --git a/exercises/traits/traits2.rs b/exercises/traits/traits2.rs index 7f5014d0..34b0ce29 100644 --- a/exercises/traits/traits2.rs +++ b/exercises/traits/traits2.rs @@ -10,16 +10,16 @@ // No boiler plate code this time, // you can do this! -// I AM NOT DONE - trait AppendBar { fn append_bar(self) -> Self; } -//TODO: Add your code here - - - +impl AppendBar for Vec { + fn append_bar(mut self) -> Self { + self.push(String::from("Bar")); + self + } +} #[cfg(test)] mod tests {