Struct napchart::ChartLane[][src]

pub struct ChartLane {
    pub locked: bool,
    // some fields omitted
}
Expand description

A single lane of a napchart

Fields

locked: bool

Whether the lane is locked on napchart.com. Has no effect in rust.

Implementations

Clear all elements from the lane.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
lane.add_element(0, 60).unwrap();
lane.add_element(60, 120).unwrap();
lane.add_element(120, 180).unwrap();
assert!(!lane.is_empty());
lane.clear();
assert!(lane.is_empty());

True if the lane has no elements.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
assert!(lane.is_empty());
lane.add_element(0, 60).unwrap();
assert!(!lane.is_empty());

The number of elements in the lane.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
assert_eq!(lane.elems_len(), 0);
lane.add_element(0, 60).unwrap();
lane.add_element(60, 120).unwrap();
lane.add_element(120, 180).unwrap();
assert_eq!(lane.elems_len(), 3);

Add a new element to the lane. Start and end must both be between [0 and 1440). Error if the new element would overlap with the existing elements.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
assert!(lane.add_element(0, 30).is_ok());
assert!(lane.add_element(15, 45).is_err());
assert!(lane.add_element(30, 60).is_ok());
assert_eq!(lane.elems_len(), 2);

Get an iterator over the elements in the lane.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
lane.add_element(0, 60).unwrap();
lane.add_element(60, 120).unwrap();
lane.add_element(120, 180).unwrap();
let mut iter = lane.elems_iter();
assert_eq!(iter.next().unwrap().get_position(), (0, 60));
assert_eq!(iter.next().unwrap().get_position(), (60, 120));
assert_eq!(iter.next().unwrap().get_position(), (120, 180));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.