facet-core 0.46.0

Core reflection traits and types for the facet ecosystem - provides the Facet trait, Shape metadata, and type-erased pointers
Documentation
use facet_core::{Facet, PointerType, Type};

#[test]
fn shape_name_string_slice_const_ptr() {
    let shape = <*const str as Facet>::SHAPE;
    match shape.ty {
        Type::Pointer(PointerType::Raw(vpt)) => {
            assert!(!vpt.mutable);
            assert_eq!(vpt.target.to_string(), "str");
        }
        _ => panic!("wrong type {:?}", shape.ty),
    }
}

#[test]
fn shape_name_string_slice_mut_ptr() {
    let shape = <*mut str as Facet>::SHAPE;
    match shape.ty {
        Type::Pointer(PointerType::Raw(vpt)) => {
            assert!(vpt.mutable);
            assert_eq!(vpt.target.to_string(), "str");
        }
        _ => panic!("wrong type {:?}", shape.ty),
    }
}

#[test]
fn shape_name_string_slice_ref() {
    let shape = <&str as Facet>::SHAPE;
    match shape.ty {
        Type::Pointer(PointerType::Reference(vpt)) => {
            assert!(!vpt.mutable);
            assert_eq!(vpt.target.to_string(), "str");
        }
        _ => panic!("wrong type {:?}", shape.ty),
    }
}