rust/src/test/ui/deref-mut-on-ref.rs
2019-07-27 18:56:16 +03:00

16 lines
244 B
Rust

// run-pass
// 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);
}