2020-02-25 09:48:50 +00:00
|
|
|
trait AppendBar {
|
|
|
|
fn append_bar(self) -> Self;
|
|
|
|
}
|
|
|
|
|
2024-06-27 10:58:44 +01:00
|
|
|
// TODO: Implement the trait `AppendBar` for a vector of strings.
|
2024-07-02 13:28:08 +01:00
|
|
|
// `append_bar` should push the string "Bar" into the vector.
|
2020-02-25 09:48:50 +00:00
|
|
|
|
2024-04-17 21:46:21 +01:00
|
|
|
fn main() {
|
|
|
|
// You can optionally experiment here.
|
|
|
|
}
|
|
|
|
|
2020-02-25 09:48:50 +00: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 10:58:44 +01:00
|
|
|
assert_eq!(foo.pop().unwrap(), "Bar");
|
|
|
|
assert_eq!(foo.pop().unwrap(), "Foo");
|
2020-02-25 09:48:50 +00:00
|
|
|
}
|
2020-02-25 11:00:09 +00:00
|
|
|
}
|