Line

Struct Line 

Source
pub struct Line<T> {
    pub start: T,
    pub end: T,
}
Expand description

An abstract “line”. Represents any type that has a start and an end

Fields§

§start: T

The start position of a line

§end: T

The end position of a line

Implementations§

Source§

impl<T> Line<T>

Source

pub fn map<R, F>(self, f: F) -> Line<R>
where F: Fn(T) -> R,

Applies the function f to both the width and height

This is used to transform a Line<T> into a Line<R>.

Source§

impl Line<bool>

Source

pub const TRUE: Line<bool>

A Line<bool> with both start and end set to true

Source

pub const FALSE: Line<bool>

A Line<bool> with both start and end set to false

Source§

impl<T> Line<T>
where T: Add + Copy,

Source

pub fn sum(&self) -> <T as Add>::Output

Adds the start and end values together and returns the result

Source§

impl<S> Line<GridPlacement<S>>
where S: CheapCloneStr,

Source

pub fn into_origin_zero_ignoring_named( &self, explicit_track_count: u16, ) -> Line<GenericGridPlacement<OriginZeroLine>>

Apply a mapping function if the GridPlacement is a Line. Otherwise return self unmodified.

Source§

impl<T> Line<GenericGridPlacement<T>>
where T: GridCoordinate,

Source

pub fn indefinite_span(&self) -> u16

Resolves the span for an indefinite placement (a placement that does not consist of two Tracks). Panics if called on a definite placement

Source§

impl<S> Line<GridPlacement<S>>
where S: CheapCloneStr,

Source

pub fn is_definite(&self) -> bool

Whether the track position is definite in this axis (or the item will need auto placement) The track position is definite if least one of the start and end positions is a NON-ZERO track index (0 is an invalid line in GridLine coordinates, and falls back to “auto” which is indefinite)

Source§

impl Line<GenericGridPlacement<GridLine>>

Source

pub fn is_definite(&self) -> bool

Whether the track position is definite in this axis (or the item will need auto placement) The track position is definite if least one of the start and end positions is a NON-ZERO track index (0 is an invalid line in GridLine coordinates, and falls back to “auto” which is indefinite)

Source

pub fn into_origin_zero( &self, explicit_track_count: u16, ) -> Line<GenericGridPlacement<OriginZeroLine>>

Apply a mapping function if the GridPlacement is a Track. Otherwise return self unmodified.

Source§

impl Line<GenericGridPlacement<OriginZeroLine>>

Source

pub fn is_definite(&self) -> bool

Whether the track position is definite in this axis (or the item will need auto placement) The track position is definite if least one of the start and end positions is a track index

Source

pub fn resolve_definite_grid_lines(&self) -> Line<OriginZeroLine>

If at least one of the of the start and end positions is a track index then the other end can be resolved into a track index purely based on the information contained with the placement specification

Source

pub fn resolve_absolutely_positioned_grid_tracks( &self, ) -> Line<Option<OriginZeroLine>>

For absolutely positioned items:

  • Tracks resolve to definite tracks
  • For Spans:
    • If the other position is a Track, they resolve to a definite track relative to the other track
    • Else resolve to None
  • Auto resolves to None

When finally positioning the item, a value of None means that the item’s grid area is bounded by the grid container’s border box on that side.

Source

pub fn resolve_indefinite_grid_tracks( &self, start: OriginZeroLine, ) -> Line<OriginZeroLine>

If neither of the start and end positions is a track index then the other end can be resolved into a track index if a definite start position is supplied externally

Source§

impl<T> Line<T>
where T: TaffyZero,

Source

pub const fn zero() -> Line<T>

Returns a Line where both the start and end values are the zero value of the contained type (e.g. 0.0, Some(0.0), or Dimension::Length(0.0))

Source§

impl<T> Line<T>
where T: TaffyAuto,

Source

pub const fn auto() -> Line<T>

Returns a Line where both the start and end values are the auto value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

Source§

impl<T> Line<T>
where T: TaffyMinContent,

Source

pub const fn min_content() -> Line<T>

Returns a Line where both the start and end values are the min_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

Source§

impl<T> Line<T>
where T: TaffyMaxContent,

Source

pub const fn max_content() -> Line<T>

Returns a Line where both the start and end values are the max_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

Source§

impl<T> Line<T>
where T: TaffyFitContent,

Source

pub fn fit_content(argument: LengthPercentage) -> Line<T>

Returns a Line with start and end set to the same fit-content(…) value with the given argument.

Source§

impl<T> Line<T>
where T: FromLength,

Source

pub fn length<Input>(value: Input) -> Line<T>
where Input: Into<f32> + Copy,

Returns a Line where both the start and end values are the same given absolute length

Source§

impl<T> Line<T>
where T: FromPercent,

Source

pub fn percent<Input>(percent_value: Input) -> Line<T>
where Input: Into<f32> + Copy,

Returns a Line where both the start and end values are the constant percent value of the contained type (e.g. 2.1, Some(2.1), or Dimension::Length(2.1))

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Line<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Line<T>
where T: Debug,

Source§

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

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

impl<S> Default for Line<GridPlacement<S>>
where S: CheapCloneStr,

Represents the start and end points of a GridItem within a given axis

Source§

fn default() -> Line<GridPlacement<S>>

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

impl<T> FromLength for Line<T>
where T: FromLength,

Source§

fn from_length<Input>(value: Input) -> Line<T>
where Input: Into<f32> + Copy,

Converts into an Into<f32> into Self
Source§

impl<T> FromPercent for Line<T>
where T: FromPercent,

Source§

fn from_percent<Input>(percent: Input) -> Line<T>
where Input: Into<f32> + Copy,

Converts into an Into<f32> into Self
Source§

impl<T> PartialEq for Line<T>
where T: PartialEq,

Source§

fn eq(&self, other: &Line<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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<T> TaffyAuto for Line<T>
where T: TaffyAuto,

Source§

const AUTO: Line<T>

The auto value for type implementing TaffyAuto
Source§

impl<T> TaffyFitContent for Line<T>
where T: TaffyFitContent,

Source§

fn fit_content(argument: LengthPercentage) -> Line<T>

Converts a LengthPercentage into Self
Source§

impl<S> TaffyGridLine for Line<GridPlacement<S>>
where S: CheapCloneStr,

Source§

fn from_line_index(index: i16) -> Line<GridPlacement<S>>

Converts an i16 into Self
Source§

impl<S> TaffyGridSpan for Line<GridPlacement<S>>
where S: CheapCloneStr,

Source§

fn from_span(span: u16) -> Line<GridPlacement<S>>

Converts an u16 into Self
Source§

impl<T> TaffyMaxContent for Line<T>
where T: TaffyMaxContent,

Source§

const MAX_CONTENT: Line<T>

The max_content value for type implementing TaffyZero
Source§

impl<T> TaffyMinContent for Line<T>
where T: TaffyMinContent,

Source§

const MIN_CONTENT: Line<T>

The min_content value for type implementing TaffyZero
Source§

impl<T> TaffyZero for Line<T>
where T: TaffyZero,

Source§

const ZERO: Line<T>

The zero value for type implementing TaffyZero
Source§

impl<T> Copy for Line<T>
where T: Copy,

Source§

impl<T> Eq for Line<T>
where T: Eq,

Source§

impl<T> StructuralPartialEq for Line<T>

Auto Trait Implementations§

§

impl<T> Freeze for Line<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Line<T>
where T: RefUnwindSafe,

§

impl<T> Send for Line<T>
where T: Send,

§

impl<T> Sync for Line<T>
where T: Sync,

§

impl<T> Unpin for Line<T>
where T: Unpin,

§

impl<T> UnwindSafe for Line<T>
where T: 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,