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