rust/src/test/run-pass/deref-mut-on-ref.rs
2018-12-25 21:08:33 -07:00

15 lines
232 B
Rust

// Test that `&mut T` implements `DerefMut<T>`
use std::ops::{Deref, DerefMut};
fn inc<T: Deref<Target=isize> + DerefMut>(mut t: T) {
*t += 1;
}
fn main() {
let mut x: isize = 5;
inc(&mut x);
assert_eq!(x, 6);
}