diff options
| author | bors <bors@rust-lang.org> | 2020-02-25 21:27:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-25 21:27:39 +0000 |
| commit | 78295ce92fa5842e3eb1a05979fd22c4cb8191e8 (patch) | |
| tree | 1e0c866e0641d7c4e50837b5418360cd9f9daf13 /exercises/traits/traits2.rs | |
| parent | 358fb473cd3ebf06085b58f8c7ff1f649ec6ec7a (diff) | |
| parent | dc84aacc65392172164b728813449ecda8c3b6e6 (diff) | |
Auto merge of #274 - sjmann:master, r=fmoko
chore: fixed merge conflicts from traits exercises added by s-marios
I hope this doesn't step on any toes but I wanted to try the traits exercises from #216 so I updated them to match the new structure with hints included in info.toml
Diffstat (limited to 'exercises/traits/traits2.rs')
| -rw-r--r-- | exercises/traits/traits2.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/exercises/traits/traits2.rs b/exercises/traits/traits2.rs new file mode 100644 index 0000000..7f5014d --- /dev/null +++ b/exercises/traits/traits2.rs @@ -0,0 +1,35 @@ +// traits2.rs +// +// 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! + +// I AM NOT DONE + +trait AppendBar { + fn append_bar(self) -> Self; +} + +//TODO: Add your code here + + + + +#[cfg(test)] +mod tests { + use super::*; + + #[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")); + } + +} |
