errorversion/examples/private_field_deref.rs
2026-05-16 20:31:48 +02:00

26 lines
361 B
Rust

mod private {
pub struct Foo {
field: i32,
bar: Bar,
}
pub struct Bar {
pub field: u32,
}
impl std::ops::Deref for Foo {
type Target = Bar;
fn deref(&self) -> &Self::Target {
&self.bar
}
}
}
use private::Foo;
fn example(f: Foo) {
let a: i32 = f.field;
}
fn main() {}