1use crate::{Def, ScalarAffinity, ScalarDef, ValueVTable, value_vtable};
2use crate::{Facet, Shape, Type, UserType};
3
4#[repr(transparent)]
6pub struct Opaque<T>(pub T);
7
8unsafe impl<'a, T: 'a> Facet<'a> for Opaque<T> {
9 const VTABLE: &'static ValueVTable =
12 &const { value_vtable!((), |f, _opts| write!(f, "{}", Self::SHAPE.type_identifier)) };
13
14 const SHAPE: &'static Shape<'static> = &const {
15 Shape::builder_for_sized::<Self>()
16 .type_identifier("Opaque")
17 .ty(Type::User(UserType::Opaque))
18 .def(Def::Scalar(
19 ScalarDef::builder()
20 .affinity(&const { ScalarAffinity::opaque().build() })
21 .build(),
22 ))
23 .build()
24 };
25}