pub struct YarnRepeat { /* private fields */ }Expand description
Repeating sequence of yarns used in the warp or weft
Implementations§
Source§impl YarnRepeat
impl YarnRepeat
Sourcepub fn set_sequence(&mut self, sequence: &[Rc<Yarn>])
pub fn set_sequence(&mut self, sequence: &[Rc<Yarn>])
Set the repat
Sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Set the offset
Sourcepub fn try_get(&self, index: usize) -> Option<&Rc<Yarn>>
pub fn try_get(&self, index: usize) -> Option<&Rc<Yarn>>
Gets the appropriate yarn for the given index, returns None if the sequence is empty
§Examples
let mut seq = YarnRepeat::new();
assert_eq!(seq.try_get(1), None);
let yarn_1 = Rc::new(Yarn::default());
let mut yarn_2 = Yarn::default();
yarn_2.set_color(Color(255,255,255));
let yarn_2 = Rc::new(yarn_2);
seq.set_sequence(&[Rc::clone(&yarn_1), Rc::clone(&yarn_2)]);
assert_eq!(seq.try_get(3).unwrap(), &yarn_2);
seq.set_offset(1);
assert_eq!(seq.try_get(3).unwrap(), &yarn_1);Trait Implementations§
Source§impl Clone for YarnRepeat
impl Clone for YarnRepeat
Source§fn clone(&self) -> YarnRepeat
fn clone(&self) -> YarnRepeat
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 YarnRepeat
impl Debug for YarnRepeat
Source§impl Default for YarnRepeat
impl Default for YarnRepeat
Source§fn default() -> YarnRepeat
fn default() -> YarnRepeat
Returns the “default value” for a type. Read more
Source§impl PartialEq for YarnRepeat
impl PartialEq for YarnRepeat
impl StructuralPartialEq for YarnRepeat
Auto Trait Implementations§
impl Freeze for YarnRepeat
impl RefUnwindSafe for YarnRepeat
impl !Send for YarnRepeat
impl !Sync for YarnRepeat
impl Unpin for YarnRepeat
impl UnwindSafe for YarnRepeat
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