I've noticed that, given a P<SomeStruct>
, accessing fields of the SomeStruct
directly on the pointer seems to work, and I'm not sure why that is. For example, this code compiles and works as expected (prints "1234"):
#![feature(rustc_private)]
extern crate syntax;
use syntax::ptr::P;
struct Baz {
id: String,
}
fn foo() {
let mut struct_pointer: P<Baz> = P(Baz {
id: "1234".to_string(),
});
println!("{}", struct_pointer.id);
}
What language feature is allowing me to access the id
field on the struct_pointer
binding? Dereferencing? Coercion? And is there any way to tell that this sort of thing will work by looking at the docs for P
?