Implement AppendBar trait for Vec<String>

This commit is contained in:
Rock070 2024-01-03 00:16:38 +08:00
parent 6d67fc122f
commit 46060cf08f

View File

@ -8,13 +8,18 @@
//
// Execute `rustlings hint traits2` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
trait AppendBar {
fn append_bar(self) -> Self;
}
// TODO: Implement trait `AppendBar` for a vector of strings.
impl AppendBar for Vec<String> {
fn append_bar(&mut self) -> Vec<String> {
let vec = self.to_vec().push(String::from("Bar"));
vec
}
}
#[cfg(test)]
mod tests {