macro_tools/attr_prop/
singletone.rs1use core ::marker ::PhantomData;
15
16use crate :: *;
17#[ derive( Debug, Default, Clone, Copy ) ]
22pub struct AttributePropertySingletoneMarker;
23
24#[ derive( Debug, Default, Clone, Copy ) ]
30pub struct AttributePropertySingletone< Marker = AttributePropertySingletoneMarker >(bool, ::core ::marker ::PhantomData< Marker >);
31
32impl< Marker > AttributePropertySingletone< Marker >
33{
34 #[ must_use ]
36 #[ inline( always ) ]
37 pub fn internal(self) -> bool
38 {
39 self.0
40 }
41
42 #[ must_use ]
44 #[ inline( always ) ]
45 pub fn ref_internal( &self ) -> &bool
46 {
47 &self.0
48 }
49}
50
51impl< Marker, IntoT > Assign< AttributePropertySingletone<Marker >, IntoT> for AttributePropertySingletone< Marker >
52where
53 IntoT: Into< AttributePropertySingletone<Marker >>,
54{
55 #[ inline( always ) ]
56 fn assign(&mut self, component: IntoT)
57 {
58 *self = component.into();
59 }
60}
61
62impl< Marker > AttributePropertyComponent for AttributePropertySingletone< Marker >
63where
64 Marker: AttributePropertyComponent,
65{
66 const KEYWORD: &'static str = Marker ::KEYWORD;
67}
68
69impl< Marker > From< bool > for AttributePropertySingletone< Marker >
70{
71 #[ inline( always ) ]
72 #[ allow( clippy ::default_constructed_unit_structs ) ]
73 fn from(src: bool) -> Self
74 {
75 Self(src, PhantomData ::default())
76 }
77}
78
79impl< Marker > From< AttributePropertySingletone<Marker >> for bool
80{
81 #[ inline( always ) ]
82 fn from(src: AttributePropertySingletone< Marker >) -> Self
83 {
84 src.0
85 }
86}
87
88impl< Marker > core ::ops ::Deref for AttributePropertySingletone< Marker >
89{
90 type Target = bool;
91
92 #[ inline( always ) ]
93 fn deref( &self ) -> &bool
94 {
95 &self.0
96 }
97}
98
99impl< Marker > AsRef< bool > for AttributePropertySingletone< Marker >
100{
101 #[ inline( always ) ]
102 fn as_ref( &self ) -> &bool
103 {
104 &self.0
105 }
106}