Skip to main content

Nesting

Struct Nesting 

Source
#[non_exhaustive]
pub struct Nesting { pub level: u8, }
Expand description

How deep a row sits inside a set: a tree, an outline, a threaded list.

RowPart below already names what is in a row; nothing named where a row sits relative to its siblings, so every consumer that had a hierarchy carried a bare number and every renderer decided for itself what one was worth.

§Not Depth, and the collision is the reason

Depth is taken and means something else entirely: surface bevel – Flat, Raised, Well, Sunken, Overlay – a fact about a surface rather than a position in a hierarchy. Two meanings under one word in one crate is the collision that costs a reader an hour, and the word this concept wants is the one that would cause it.

§The magnitude is the renderer’s, and that is the precedent

Awaiting is the shape: this crate names the fact and declines to name what it is worth. makeover-webview writes the rule as a custom property with a fallback – the way it writes margin-inline-start: var(--awaiting-gap, 0.5ch) – so a level has one answer per renderer and an app can override it. A terminal spends columns, a browser spends inline space, and neither number belongs in a description.

§Zero is a real answer

top is the default and is what a flat list says: every row is at the top level, which is true and is the reading a renderer needs. An Option here would make “not nested” and “nested at zero” two spellings of one thing, the same argument Discovery’s indexable makes about defaults that are meaningful.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§level: u8

How many levels in, counting from zero.

u8 because a hierarchy a reader can follow is not 256 deep, and a renderer indenting by a level has to multiply it by something – a wider integer here is a wider integer in every renderer’s arithmetic for a range nothing will use.

Implementations§

Source§

impl Nesting

Source

pub const fn top() -> Self

The top level: not nested. The default, and what a flat list says.

Source

pub const fn at(level: u8) -> Self

A row this many levels in.

Source

pub const fn is_nested(self) -> bool

Whether this row sits under another.

The question every renderer asks before it spends anything on indenting, answered once here rather than by a > 0 in each – which is Awaiting::is_determinate’s reason too.

Trait Implementations§

Source§

impl Clone for Nesting

Source§

fn clone(&self) -> Nesting

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 Copy for Nesting

Source§

impl Debug for Nesting

Source§

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

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

impl Default for Nesting

Source§

fn default() -> Nesting

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

impl Eq for Nesting

Source§

impl Hash for Nesting

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Nesting

Source§

fn cmp(&self, other: &Nesting) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Nesting

Source§

fn eq(&self, other: &Nesting) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Nesting

Source§

fn partial_cmp(&self, other: &Nesting) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Nesting

Auto Trait Implementations§

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 = !

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.