1
0
Fork 0
mirror of https://github.com/notohh/rustlings.git synced 2024-12-20 23:48:09 -05:00
rustlings/exercises/15_traits/traits2.rs

23 lines
490 B
Rust
Raw Normal View History

2020-02-25 04:48:50 -05:00
trait AppendBar {
fn append_bar(self) -> Self;
}
2024-06-27 05:58:44 -04:00
// TODO: Implement the trait `AppendBar` for a vector of strings.
2024-07-02 08:28:08 -04:00
// `append_bar` should push the string "Bar" into the vector.
2020-02-25 04:48:50 -05:00
fn main() {
// You can optionally experiment here.
}
2020-02-25 04:48:50 -05:00
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn is_vec_pop_eq_bar() {
let mut foo = vec![String::from("Foo")].append_bar();
2024-06-27 05:58:44 -04:00
assert_eq!(foo.pop().unwrap(), "Bar");
assert_eq!(foo.pop().unwrap(), "Foo");
2020-02-25 04:48:50 -05:00
}
2020-02-25 06:00:09 -05:00
}