use core ::marker ::PhantomData;
use crate :: *;
#[ derive( Debug, Default, Clone, Copy ) ]
pub struct AttributePropertyOptionalSingletoneMarker;
#[ derive( Debug, Default, Clone, Copy ) ]
pub struct AttributePropertyOptionalSingletone< Marker = AttributePropertyOptionalSingletoneMarker >(
Option< bool >,
::core ::marker ::PhantomData< Marker >,
);
impl< Marker > AttributePropertyOptionalSingletone< Marker >
{
#[ inline ]
#[ must_use ]
pub fn value(self, default: bool) -> bool
{
if self.0.is_none()
{
return default;
}
self.0.unwrap()
}
#[ inline( always ) ]
#[ must_use ]
pub fn internal(self) -> Option< bool >
{
self.0
}
#[ must_use ]
#[ inline( always ) ]
pub fn ref_internal( &self ) -> Option< &bool >
{
self.0.as_ref()
}
}
impl< Marker, IntoT > Assign< AttributePropertyOptionalSingletone<Marker >, IntoT> for AttributePropertyOptionalSingletone< Marker >
where
IntoT: Into< AttributePropertyOptionalSingletone<Marker >>,
{
#[ inline( always ) ]
#[ allow( clippy ::single_match ) ]
fn assign(&mut self, component: IntoT)
{
let component = component.into();
match component.0
{
Some(val) =>
{
self.0 = Some(val);
}
None => {}
}
}
}
impl< Marker > AttributePropertyComponent for AttributePropertyOptionalSingletone< Marker >
where
Marker: AttributePropertyComponent,
{
const KEYWORD: &'static str = Marker ::KEYWORD;
}
impl< Marker > From< bool > for AttributePropertyOptionalSingletone< Marker >
{
#[ inline( always ) ]
#[ allow( clippy ::default_constructed_unit_structs ) ]
fn from(src: bool) -> Self
{
Self(Some(src), PhantomData ::default())
}
}
impl< Marker > From< Option< bool >> for AttributePropertyOptionalSingletone< Marker >
{
#[ inline( always ) ]
#[ allow( clippy ::default_constructed_unit_structs ) ]
fn from(src: Option< bool >) -> Self
{
Self(src, PhantomData ::default())
}
}
impl< Marker > From< AttributePropertyOptionalSingletone<Marker >> for Option< bool >
{
#[ inline( always ) ]
fn from(src: AttributePropertyOptionalSingletone< Marker >) -> Self
{
src.0
}
}
impl< Marker > core ::ops ::Deref for AttributePropertyOptionalSingletone< Marker >
{
type Target = Option< bool >;
#[ inline( always ) ]
fn deref( &self ) -> &Option< bool >
{
&self.0
}
}
impl< Marker > AsRef< Option< bool >> for AttributePropertyOptionalSingletone< Marker >
{
#[ inline( always ) ]
fn as_ref( &self ) -> &Option< bool >
{
&self.0
}
}