https://docs.rs/facet-core/0.44.3/src/facet_core/types/def/mod.rs.html#217-219
A &Foos ::SHAPE.def debug impl prints SmartPointer<Foo> which is wrong since &T is not a smart pointer.
That is due to:
https://docs.rs/facet-core/0.44.3/src/facet_core/types/def/mod.rs.html#217-219
which is Some due to the way Facet is implemented for &T
https://docs.rs/facet-core/0.44.3/src/facet_core/impls/core/reference.rs.html#252
Discovered with the following code:
#[cfg(test)]
mod tests {
use facet::{Def, Facet, KnownPointer};
use facet_reflect::Peek;
#[derive(Debug, Facet)]
struct Foo {
value: String,
}
#[facet_testhelpers::test]
fn shared_reference() {
let a = Foo {
value: "aaaa".to_string(),
};
println!("{:#?}", <&Foo as Facet<'_>>::SHAPE.def);
assert!(
matches!(<&Foo as Facet<'_>>::SHAPE.def, Def::Pointer(p) if p.known == Some(KnownPointer::SharedReference))
);
let ref_a: &Foo = &a;
let ref_ref_a: &&Foo = &ref_a;
let peek = Peek::new(ref_ref_a);
println!("{:#?}", peek.shape().def); // `Undefined`
assert!(
matches!(peek.shape().def, Def::Pointer(p) if p.known == Some(KnownPointer::SharedReference))
);
}
}
https://docs.rs/facet-core/0.44.3/src/facet_core/types/def/mod.rs.html#217-219
A
&Foos::SHAPE.defdebug impl printsSmartPointer<Foo>which is wrong since&Tis not a smart pointer.That is due to:
https://docs.rs/facet-core/0.44.3/src/facet_core/types/def/mod.rs.html#217-219
which is Some due to the way
Facetis implemented for&Thttps://docs.rs/facet-core/0.44.3/src/facet_core/impls/core/reference.rs.html#252
Discovered with the following code: