pub struct YarnPalette(/* private fields */);Expand description
Palette of yarns to be used in the weaving
Implementations§
Source§impl YarnPalette
impl YarnPalette
Sourcepub fn new() -> YarnPalette
pub fn new() -> YarnPalette
Construct a new YarnPalette
Sourcepub fn remove_unused_yarns(&mut self) -> Vec<Yarn>
pub fn remove_unused_yarns(&mut self) -> Vec<Yarn>
Removes yarns that are not used outside the palette and returns a Vec of the removed yarns
§Examples
let mut palette = YarnPalette::new();
palette.use_yarn(Yarn::default());
assert_eq!(palette.remove_unused_yarns(), vec![Yarn::default()]);
assert_eq!(palette.len(), 0);
let yarn = palette.use_yarn(Yarn::default());
assert_eq!(palette.remove_unused_yarns(), vec![]);
assert_eq!(Rc::strong_count(&yarn), 2);Sourcepub fn use_yarn(&mut self, yarn: Yarn) -> Rc<Yarn>
pub fn use_yarn(&mut self, yarn: Yarn) -> Rc<Yarn>
Adds yarn to palette if not there. Returns reference to yarn owned by palette
Trait Implementations§
Source§impl Clone for YarnPalette
impl Clone for YarnPalette
Source§fn clone(&self) -> YarnPalette
fn clone(&self) -> YarnPalette
Returns a duplicate 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 Debug for YarnPalette
impl Debug for YarnPalette
Source§impl Default for YarnPalette
impl Default for YarnPalette
Source§fn default() -> YarnPalette
fn default() -> YarnPalette
Returns the “default value” for a type. Read more
Source§impl<'a> IntoIterator for &'a YarnPalette
impl<'a> IntoIterator for &'a YarnPalette
Source§impl PartialEq for YarnPalette
impl PartialEq for YarnPalette
impl StructuralPartialEq for YarnPalette
Auto Trait Implementations§
impl Freeze for YarnPalette
impl RefUnwindSafe for YarnPalette
impl !Send for YarnPalette
impl !Sync for YarnPalette
impl Unpin for YarnPalette
impl UnwindSafe for YarnPalette
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