mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-03 09:19:18 +00:00
Implement AppendBar trait for Vec<String>
This commit is contained in:
parent
6d67fc122f
commit
46060cf08f
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user