Skip to main content

Fit

Enum Fit 

Source
#[non_exhaustive]
pub enum Fit { Natural, Cover, Contain, }
Expand description

Something the user can do, and what it costs to say so.

Added 0.17.0, out of quasi-tui: the terminal renderer had drawn one of these for months and every other consumer that wanted a button had written its own, because this layer named RowPart::Actions as a slot and never named the thing that goes in it. Beside Meter and Figure for the reason those are here: a renderer that is handed the parts has to decide how to say them, and a renderer that is handed a finished string has already had the decision made for it.

No address. Where a control goes is the app’s business and every host follows it differently — an hx-get, a protocol URL, a function call — so the description says what the control is and the caller keeps what it does. That is the same split Choice makes.

No confirmation flag either, and that one is a finding rather than an omission: a question asked after a control is pressed belongs to whatever is holding the interaction, and a renderer that drew it would be asking before there was anything to answer. How a picture sits in the box it is given.

An intent rather than a value, so a renderer picks the expression it has: object-fit in a webview, a texture’s UV rect in egui, and in a terminal a choice about how many cells the blit gets. Named because MNW already makes the distinction deliberately at 17 sites and makes it three different ways, which is a policy the app decided rather than one a shared crate would be picking by accident.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Natural

The picture’s own proportions, and the box takes the height they imply.

The default because it is the only one that shows the whole picture at its own shape, so a renderer that ignores this enum entirely is still right about the common case. A screenshot wants this; the shipped MNW carousel sets no object-fit at all, which is this.

§

Cover

Fill the box and crop whatever does not fit.

For a picture in a slot whose shape the layout fixed: a thumbnail, an avatar, cover art. 15 of MNW’s 17 sites.

§

Contain

Fit inside the box whole, leaving space on two sides.

The letterbox. For when the whole picture matters more than filling the space, and the space is not the picture’s shape.

Trait Implementations§

Source§

impl Clone for Fit

Source§

fn clone(&self) -> Fit

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 Fit

Source§

impl Debug for Fit

Source§

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

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

impl Default for Fit

Source§

fn default() -> Fit

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

impl Eq for Fit

Source§

impl Hash for Fit

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 PartialEq for Fit

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Fit

Auto Trait Implementations§

§

impl Freeze for Fit

§

impl RefUnwindSafe for Fit

§

impl Send for Fit

§

impl Sync for Fit

§

impl Unpin for Fit

§

impl UnsafeUnpin for Fit

§

impl UnwindSafe for Fit

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.