Skip to main content

Fact

Struct Fact 

Source
pub struct Fact<'a> {
    pub label: &'a str,
    pub value: &'a str,
}
Expand description

One labelled fact: what it is called, and what it says.

The definition-list pair every record screen has and no member named. Five goingson panes were saying it as list { row "Label" { meta value } } – the task pane’s metadata, events, contacts, the mail reader and settings’ About – and two of them carry a comment admitting the vocabulary had no word for a definition list. The task pane’s own doc calls a row “the nearest thing the vocabulary has to a definition list”, which is a workaround describing itself.

§Why this is not a Column pair, or a one-row table

A table’s columns are a promise about many rows: they earn their headings, their sort, their narrowing rules and their floors because the same shape repeats down the screen. A pane of facts has one of each, so every one of those is machinery with nothing to do, and the heading row a table wants is exactly what a facts pane must not draw.

The measured symptom, which is what makes this a member rather than a preference: rendered as rows, each value starts after its own label, so there is no value column and the eye cannot run down it. Four widths of a ui-fuzz run found the same ragged edge on About, the event pane and the mail reader.

§The rule a renderer owes it

The values line up. That is the whole point and the one thing a row list cannot do: one label column wide enough for the longest label, every value starting at the same place. A webview does it with a description list, a terminal with two padded columns, egui with a two-column grid. None of them may fall back to running the value straight after the label.

The value is the fact and reads like one. goingson had this backwards: its values were drawn muted and its labels were not, so the part a person came for was the quieter of the two. The label is the noun and reads back; the value takes content. Same rule RowPart already states for a row’s primary against its meta, and the same one Figure states for a value against its caption.

§What it is not

A form. A fact is read, not edited; the moment one of these needs to change it is a Field and it belongs in a form. Nothing here carries a name to submit under, deliberately, so the two cannot be confused at the call site.

Fields§

§label: &'a str

What the fact is called. The noun, which reads back.

§value: &'a str

What it says, already formatted the way the app means it to read.

Text, for Figure::value’s reason: only the app knows whether a date reads as 2d ago or 20 Sep, and a renderer handed a timestamp would have to guess. The five sites this member replaces were all formatting before they built the row.

Implementations§

Source§

impl<'a> Fact<'a>

Source

pub const fn new(label: &'a str, value: &'a str) -> Self

A fact, from its label and its value.

Source

pub const fn is_empty(&self) -> bool

Whether the value is worth drawing.

A record screen reads its facts off a row that has holes in it – no project, no due date, no timezone – and every one of the five sites was guarding its row with a when for exactly that. A renderer skips an empty fact rather than drawing a label with nothing after it, which is the one reading that is never wanted: a labelled blank says the value is missing, when what is true is that there is no such fact.

Trait Implementations§

Source§

impl<'a> Clone for Fact<'a>

Source§

fn clone(&self) -> Fact<'a>

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<'a> Copy for Fact<'a>

Source§

impl<'a> Debug for Fact<'a>

Source§

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

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

impl<'a> Eq for Fact<'a>

Source§

impl<'a> Hash for Fact<'a>

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<'a> Ord for Fact<'a>

Source§

fn cmp(&self, other: &Fact<'a>) -> 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<'a> PartialEq for Fact<'a>

Source§

fn eq(&self, other: &Fact<'a>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<'a> PartialOrd for Fact<'a>

Source§

fn partial_cmp(&self, other: &Fact<'a>) -> 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<'a> StructuralPartialEq for Fact<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Fact<'a>

§

impl<'a> RefUnwindSafe for Fact<'a>

§

impl<'a> Send for Fact<'a>

§

impl<'a> Sync for Fact<'a>

§

impl<'a> Unpin for Fact<'a>

§

impl<'a> UnsafeUnpin for Fact<'a>

§

impl<'a> UnwindSafe for Fact<'a>

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

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.