Skip to main content

GridLineNames

Struct GridLineNames 

Source
pub struct GridLineNames<S: CheapCloneStr = String> {
    names: Vec<S>,
    offsets: Vec<u32>,
    resolver: HashMap<StrHasher<S>, SmallVec<[u32; 4]>, RandomState>,
}
Expand description

The names of each explicit grid line in a single axis, stored in CSR (compressed sparse row) format: a single flat Vec of names plus a Vec of offsets into it (one more offset than there are lines). The names of line i (0-indexed) are names[offsets[i]..offsets[i + 1]].

Line indices here are relative to the explicit grid; DetailedGridTracksInfo provides accessors with indices relative to the full grid (including implicit tracks).

Iterate over per-line name groups with GridLineNames::iter, or access a single line’s names with GridLineNames::line. A grid with no named lines is represented by two empty Vecs (see GridLineNames::is_empty).

Fields§

§names: Vec<S>

The names of every grid line in the axis, concatenated in line order

§offsets: Vec<u32>

Offsets into names: line i’s names are names[offsets[i]..offsets[i + 1]]. Either empty (no named lines) or of length line count + 1.

§resolver: HashMap<StrHasher<S>, SmallVec<[u32; 4]>, RandomState>

Named line lookup used to resolve arbitrary grid placements

Implementations§

Source§

impl<S: CheapCloneStr> GridLineNames<S>

Source

pub(crate) fn with_capacity( name_capacity: usize, offset_capacity: usize, ) -> Self

Create an empty GridLineNames with pre-allocated capacity

Source

pub(crate) fn start_line(&mut self)

Start a new (initially empty) line

Source

pub(crate) fn push_name(&mut self, name: S)

Append a name to the current (last) line

Source

pub(crate) fn current_line_contains(&self, name: &str) -> bool

Whether the current (last) line already contains the passed name

Source

pub(crate) fn resolve_line_names( &self, line: &Line<GridPlacement<S>>, explicit_track_count: u16, ) -> Line<GenericGridPlacement<GridLine>>

Resolve named lines and spans using the retained line-name map

Source

pub fn is_empty(&self) -> bool

Whether the axis has any named lines at all

Source

pub fn line_count(&self) -> usize

The number of grid lines represented (zero if the grid has no named lines)

Source

pub fn line(&self, line_index: usize) -> &[S]

The names of the line with the passed 0-indexed line index. Returns an empty slice if the line has no names or the index is out of range.

Source

pub fn iter(&self) -> GridLineNamesIter<'_, S>

Iterate over the name group (&[S]) of each grid line in line order

Source

pub(crate) fn iter_padded( &self, leading_empty: usize, trailing_empty: usize, ) -> GridLineNamesIter<'_, S>

Iterate over the name group (&[S]) of each grid line in line order, additionally yielding leading_empty empty groups before the stored lines and trailing_empty empty groups after them (representing unnamed implicit grid lines)

Trait Implementations§

Source§

impl<S: Clone + CheapCloneStr> Clone for GridLineNames<S>

Source§

fn clone(&self) -> GridLineNames<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + CheapCloneStr> Debug for GridLineNames<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: Default + CheapCloneStr> Default for GridLineNames<S>

Source§

fn default() -> GridLineNames<S>

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

impl<'a, S: CheapCloneStr> IntoIterator for &'a GridLineNames<S>

Available on crate feature detailed_layout_info only.
Source§

type Item = &'a [S]

The type of the elements being iterated over.
Source§

type IntoIter = GridLineNamesIter<'a, S>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<S: PartialEq + CheapCloneStr> PartialEq for GridLineNames<S>

Source§

fn eq(&self, other: &GridLineNames<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: CheapCloneStr> StructuralPartialEq for GridLineNames<S>

Auto Trait Implementations§

§

impl<S> Freeze for GridLineNames<S>

§

impl<S> RefUnwindSafe for GridLineNames<S>
where S: RefUnwindSafe,

§

impl<S> Send for GridLineNames<S>
where S: Send,

§

impl<S> Sync for GridLineNames<S>
where S: Sync,

§

impl<S> Unpin for GridLineNames<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for GridLineNames<S>

§

impl<S> UnwindSafe for GridLineNames<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.