Skip to main content

NamedLineResolver

Struct NamedLineResolver 

Source
pub(crate) struct NamedLineResolver<S: CheapCloneStr> {
    row_lines: HashMap<StrHasher<S>, SmallVec<[u32; 4]>, RandomState>,
    column_lines: HashMap<StrHasher<S>, SmallVec<[u32; 4]>, RandomState>,
    areas: HashMap<StrHasher<S>, GridTemplateArea<S>, RandomState>,
    area_column_count: u16,
    area_row_count: u16,
    explicit_column_count: u16,
    explicit_row_count: u16,
    column_line_name_pairs: Vec<(u32, S)>,
    row_line_name_pairs: Vec<(u32, S)>,
}
Expand description

Resolver that takes grid lines names and area names as input and can then be used to resolve line names of grid placement properties into line numbers.

Fields§

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

Map of row line names to line numbers. Each line name may correspond to multiple lines so we store a SmallVec

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

Map of column line names to line numbers. Each line name may correspond to multiple lines so we store a SmallVec

§areas: HashMap<StrHasher<S>, GridTemplateArea<S>, RandomState>

Map of area names to area definitions (start and end lines numbers in each axis)

§area_column_count: u16

Number of columns implied by grid area definitions

§area_row_count: u16

Number of rows implied by grid area definitions

§explicit_column_count: u16

The number of explicit columns in the grid. This is an input to the NamedLineResolver and is used when computing the fallback line when a non-existent named line is specified.

§explicit_row_count: u16

The number of explicit rows in the grid. This is an input to the NamedLineResolver and is used when computing the fallback line when a non-existent named line is specified.

§column_line_name_pairs: Vec<(u32, S)>

The (1-indexed line number, name) pairs of every named column line, in source order (template names before grid-template-areas-generated names)

§row_line_name_pairs: Vec<(u32, S)>

The (1-indexed line number, name) pairs of every named row line, in source order (template names before grid-template-areas-generated names)

Implementations§

Source§

impl<S: CheapCloneStr> NamedLineResolver<S>

Source

pub(crate) fn new( style: &impl GridContainerStyle<CustomIdent = S>, column_auto_repetitions: u16, row_auto_repetitions: u16, ) -> Self

Create and initialise a new NamedLineResolver

Source

pub(crate) fn detailed_line_names(&self, axis: AbsoluteAxis) -> GridLineNames<S>

Build the per-line name groups of the explicit grid in the passed axis as a GridLineNames, with repeat()s expanded and including the implicit <name>-start/<name>-end names generated by grid-template-areas.

Line indices are relative to the explicit grid (line 0 = start of the first explicit track).

Source

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

Resolve named lines for both the start and end of a row-axis grid placement

Source

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

Resolve named lines for both the start and end of a column-axis grid placement

Source

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

Resolve named lines for both the start and end of a grid placement

Source

pub(crate) fn populate_detailed_line_resolvers( self, rows: &mut GridLineNames<S>, columns: &mut GridLineNames<S>, )

Move the row and column line-name maps into the detailed grid information

Source

pub(crate) fn area_column_count(&self) -> u16

Get the number of columns defined by the grid areas

Source

pub(crate) fn area_row_count(&self) -> u16

Get the number of rows defined by the grid areas

Source

pub(crate) fn set_explicit_column_count(&mut self, count: u16)

Set the number of columns in the explicit grid

Source

pub(crate) fn set_explicit_row_count(&mut self, count: u16)

Set the number of rows in the explicit grid

Trait Implementations§

Source§

impl<S: CheapCloneStr> Debug for NamedLineResolver<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for NamedLineResolver<S>

§

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

§

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

§

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

§

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

§

impl<S> UnsafeUnpin for NamedLineResolver<S>

§

impl<S> UnwindSafe for NamedLineResolver<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> 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, 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.