mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
20 lines
282 B
Rust
20 lines
282 B
Rust
//@ run-pass
|
|
|
|
|
|
trait Pushable<T> {
|
|
fn push_val(&mut self, t: T);
|
|
}
|
|
|
|
impl<T> Pushable<T> for Vec<T> {
|
|
fn push_val(&mut self, t: T) {
|
|
self.push(t);
|
|
}
|
|
}
|
|
|
|
pub fn main() {
|
|
let mut v = vec![1];
|
|
v.push_val(2);
|
|
v.push_val(3);
|
|
assert_eq!(v, [1, 2, 3]);
|
|
}
|