pub struct Category<T: PartialEq> { /* private fields */ }
Expand description
The category coordinate
Implementations§
Source§impl<T: PartialEq> Category<T>
impl<T: PartialEq> Category<T>
Sourcepub fn new<S: Into<String>>(name: S, elements: Vec<T>) -> Self
pub fn new<S: Into<String>>(name: S, elements: Vec<T>) -> Self
Create a new category coordinate.
name
: The name of the categoryelements
: The vector of category elements- returns The newly created category coordinate
use plotters::prelude::*;
let category = Category::new("color", vec!["red", "green", "blue"]);
Sourcepub fn get(&self, val: &T) -> Option<Category<T>>
pub fn get(&self, val: &T) -> Option<Category<T>>
Get an element reference (tick) by its value.
val
: The value of the element- returns The optional reference
use plotters::prelude::*;
let category = Category::new("color", vec!["red", "green", "blue"]);
let red = category.get(&"red");
assert!(red.is_some());
let unknown = category.get(&"unknown");
assert!(unknown.is_none());
Sourcepub fn range(&self) -> Self
pub fn range(&self) -> Self
Create a full range over the category elements.
- returns The range including all category elements
use plotters::prelude::*;
let category = Category::new("color", vec!["red", "green", "blue"]);
let range = category.range();
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the number of elements in the category.
- returns The number of elements
use plotters::prelude::*;
let category = Category::new("color", vec!["red", "green", "blue"]);
assert_eq!(category.len(), 3);
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the category contains no elements.
- returns
true
is no elements, otherwise -false
use plotters::prelude::*;
let category = Category::new("color", vec!["red", "green", "blue"]);
assert_eq!(category.is_empty(), false);
let category = Category::new("empty", Vec::<&str>::new());
assert_eq!(category.is_empty(), true);
Trait Implementations§
Source§impl<T: PartialEq> AsRangedCoord for Category<T>
impl<T: PartialEq> AsRangedCoord for Category<T>
Source§impl<T: PartialEq> Ranged for Category<T>
impl<T: PartialEq> Ranged for Category<T>
Auto Trait Implementations§
impl<T> Freeze for Category<T>
impl<T> RefUnwindSafe for Category<T>where
T: RefUnwindSafe,
impl<T> !Send for Category<T>
impl<T> !Sync for Category<T>
impl<T> Unpin for Category<T>
impl<T> UnwindSafe for Category<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified
method
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford
method by default
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
Source§fn convert_into(self) -> U
fn convert_into(self) -> U
Convert into T with values clamped to the color defined bounds Read more
Source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
Convert into T. The resulting color might be invalid in its color space Read more
Source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
Convert into T, returning ok if the color is inside of its defined range,
otherwise an
OutOfBounds
error is returned which contains the unclamped color. Read moreSource§impl<R> IntoPartialAxis for Rwhere
R: AsRangedCoord,
impl<R> IntoPartialAxis for Rwhere
R: AsRangedCoord,
Source§fn partial_axis(
self,
axis_range: Range<<Self::CoordDescType as Ranged>::ValueType>,
) -> PartialAxis<Self::CoordDescType>
fn partial_axis( self, axis_range: Range<<Self::CoordDescType as Ranged>::ValueType>, ) -> PartialAxis<Self::CoordDescType>
Make the partial axis Read more