pub struct Matcher { /* private fields */ }Expand description
A reusable nearest-color matcher built from a fixed palette.
Implementations§
Source§impl Matcher
impl Matcher
Sourcepub fn from_colors(colors: &[&str]) -> Result<Self, InvalidColor>
pub fn from_colors(colors: &[&str]) -> Result<Self, InvalidColor>
Build a matcher from a list of unnamed color strings.
§Errors
Returns InvalidColor if any entry is not a valid color.
Sourcepub fn from_named(colors: &[(&str, &str)]) -> Result<Self, InvalidColor>
pub fn from_named(colors: &[(&str, &str)]) -> Result<Self, InvalidColor>
Sourcepub fn or(self, other: Matcher) -> Matcher
pub fn or(self, other: Matcher) -> Matcher
Combine this palette with another, returning a matcher over both.
Sourcepub fn nearest(&self, needle: &str) -> Result<Option<ColorMatch>, InvalidColor>
pub fn nearest(&self, needle: &str) -> Result<Option<ColorMatch>, InvalidColor>
Find the nearest palette color to needle.
§Errors
Returns InvalidColor if needle is not a valid color. Returns Ok(None) only if
the palette is empty.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Matcher
impl RefUnwindSafe for Matcher
impl Send for Matcher
impl Sync for Matcher
impl Unpin for Matcher
impl UnsafeUnpin for Matcher
impl UnwindSafe for Matcher
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