Enum style::color::component::ColorComponent
source · pub enum ColorComponent<ValueType> {
None,
Value(ValueType),
}
Expand description
A single color component.
Variants§
Implementations§
source§impl<ValueType> ColorComponent<ValueType>
impl<ValueType> ColorComponent<ValueType>
sourcepub fn map_value<OutType>(
self,
f: impl FnOnce(ValueType) -> OutType
) -> ColorComponent<OutType>
pub fn map_value<OutType>( self, f: impl FnOnce(ValueType) -> OutType ) -> ColorComponent<OutType>
If the component contains a value, map it to another value.
sourcepub fn into_value(self) -> ValueType
pub fn into_value(self) -> ValueType
Return the component as its value.
sourcepub fn into_value_or(self, default: ValueType) -> ValueType
pub fn into_value_or(self, default: ValueType) -> ValueType
Return the component as its value or a default value.
source§impl<ValueType: ColorComponentType> ColorComponent<ValueType>
impl<ValueType: ColorComponentType> ColorComponent<ValueType>
sourcepub fn parse<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
allow_none: bool,
origin_color: Option<&AbsoluteColor>
) -> Result<Self, ParseError<'i>>
pub fn parse<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, allow_none: bool, origin_color: Option<&AbsoluteColor> ) -> Result<Self, ParseError<'i>>
Parse a single ColorComponent.
source§impl ColorComponent<NumberOrPercentage>
impl ColorComponent<NumberOrPercentage>
sourcepub fn is_percentage(&self) -> Result<bool, ()>
pub fn is_percentage(&self) -> Result<bool, ()>
Return true if the component contains a percentage.
source§impl ColorComponent<NumberOrPercentage>
impl ColorComponent<NumberOrPercentage>
fn into_alpha(self) -> Option<f32>
Trait Implementations§
source§impl<ValueType: Clone> Clone for ColorComponent<ValueType>
impl<ValueType: Clone> Clone for ColorComponent<ValueType>
source§fn clone(&self) -> ColorComponent<ValueType>
fn clone(&self) -> ColorComponent<ValueType>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<ValueType: Debug> Debug for ColorComponent<ValueType>
impl<ValueType: Debug> Debug for ColorComponent<ValueType>
source§impl<T> From<ColorComponent<T>> for Option<T>
impl<T> From<ColorComponent<T>> for Option<T>
source§fn from(value: ColorComponent<T>) -> Self
fn from(value: ColorComponent<T>) -> Self
Converts to this type from the input type.
source§impl From<ColorComponent<f32>> for ComponentDetails
impl From<ColorComponent<f32>> for ComponentDetails
source§fn from(value: ColorComponent<f32>) -> Self
fn from(value: ColorComponent<f32>) -> Self
Converts to this type from the input type.
source§impl<ValueType> MallocSizeOf for ColorComponent<ValueType>where
ValueType: MallocSizeOf,
impl<ValueType> MallocSizeOf for ColorComponent<ValueType>where ValueType: MallocSizeOf,
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
source§impl<ValueType: PartialEq> PartialEq<ColorComponent<ValueType>> for ColorComponent<ValueType>
impl<ValueType: PartialEq> PartialEq<ColorComponent<ValueType>> for ColorComponent<ValueType>
source§fn eq(&self, other: &ColorComponent<ValueType>) -> bool
fn eq(&self, other: &ColorComponent<ValueType>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<ValueType> ToShmem for ColorComponent<ValueType>where
ValueType: ToShmem,
impl<ValueType> ToShmem for ColorComponent<ValueType>where ValueType: ToShmem,
impl<ValueType> StructuralPartialEq for ColorComponent<ValueType>
Auto Trait Implementations§
impl<ValueType> RefUnwindSafe for ColorComponent<ValueType>where ValueType: RefUnwindSafe,
impl<ValueType> Send for ColorComponent<ValueType>where ValueType: Send,
impl<ValueType> Sync for ColorComponent<ValueType>where ValueType: Sync,
impl<ValueType> Unpin for ColorComponent<ValueType>where ValueType: Unpin,
impl<ValueType> UnwindSafe for ColorComponent<ValueType>where ValueType: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where F: FnOnce(&Self) -> bool,
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> MaybeBoxed<Box<T, Global>> for T
impl<T> MaybeBoxed<Box<T, Global>> for T
source§fn maybe_boxed(self) -> Box<T, Global>
fn maybe_boxed(self) -> Box<T, Global>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert