mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
31 lines
403 B
Rust
31 lines
403 B
Rust
//@ check-pass
|
|
#![allow(dead_code)]
|
|
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() {}
|