2019-11-03 18:00:00 -06:00
|
|
|
// check-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(dead_code)]
|
2015-09-03 12:10:34 -05:00
|
|
|
use std::ops::{Deref, DerefMut};
|
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
|
|
|
|
impl Foo {
|
|
|
|
fn foo_mut(&mut self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar(Foo);
|
|
|
|
|
|
|
|
impl Deref for Bar {
|
|
|
|
type Target = Foo;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Foo {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DerefMut for Bar {
|
|
|
|
fn deref_mut(&mut self) -> &mut Foo {
|
|
|
|
&mut self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test(mut bar: Box<Bar>) {
|
|
|
|
bar.foo_mut();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|