Skip to main content

CellValue

Enum CellValue 

Source
#[non_exhaustive]
pub enum CellValue<'a> { Empty, Bool(bool), Int(i64), Float(f64), Decimal(Decimal), Text(&'a str), Timestamp(DateTime<Utc>), Icon(IconValue<'a>), Image(ImageValue<'a>), Link(LinkValue<'a>), Custom(&'a dyn GridValue), }
Expand description

A cell value. Numbers, points in time and borrowed text do not allocate.

== compares two values of one variant: floats with f64::eq (a NaN is not equal to itself, -0.0 equals 0.0), decimals by value (1.0 equals 1.00), icons by path and text, custom values by GridValue::cmp_value. Values of two variants are never equal, not even Int(1) and Float(1.0). GridRow::changed_columns diffs rows with it; CellValue::cmp_total is the order.

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.
§

Empty

No value.

§

Bool(bool)

A boolean.

§

Int(i64)

An integer.

§

Float(f64)

A floating point number.

§

Decimal(Decimal)

An exact decimal number with its scale: money, quantities with a fixed number of decimals. 12.30 shows as 12.30. Needs the decimal feature.

§

Text(&'a str)

Text borrowed from the row.

§

Timestamp(DateTime<Utc>)

A point in time. Shown in UTC as 2026-11-04 12:34:56 until a column formatter exists; another zone or format is a CellValue::Custom value with its own text. A date without a time is the timestamp of its midnight in UTC.

§

Icon(IconValue<'a>)

An icon with the text that stands for it. The body paints the icon; the text is what a screen reader, a tooltip, the quick filter, a copy and the sort read.

§

Image(ImageValue<'a>)

An image with the text that stands for it: a raster or a colour SVG that the grid’s image source (LiveGridState::with_image_source) finds by its id. Like an icon, the body paints the image and the text is what a screen reader, a tooltip, the quick filter, a copy and the sort read.

A link: its text, which the cell shows in the theme’s link colour, underlined, and the address a click on the text or Enter on the focused cell opens (LiveGridState::with_link_opener). The text is the value everywhere else, as an icon’s: the sort, the quick filter, a copy, an export and a screen reader, which hears “link” after it. Painted by the body: no element per cell.

§

Custom(&'a dyn GridValue)

A value of the application’s own type, borrowed from the row: its own order, text and export. See GridValue.

Implementations§

Source§

impl CellValue<'_>

Source

pub fn cmp_total(&self, other: &Self) -> Ordering

A total order across all values: Empty first, then Bool, numbers, Timestamp, Text, Icon and Image, and Custom last, each by value.

Numbers follow f64::total_cmp, and an Int compares exactly, as the float of its value would: Int(1) equals Float(1.0) and Int(2^53 + 1) is above Float(2^53). So -0.0 sorts just below 0.0 and Int(0), a negative NaN before -∞ and a positive NaN after +∞.

A Decimal (the decimal feature) is a number too and compares exactly by its value, whatever its scale: Decimal(1.00) equals Int(1) and Float(1.0), Decimal(0.1) is below Float(0.1), whose binary value is a little above 0.1, and a zero Decimal of any sign or scale sorts as Int(0), above -0.0.

Timestamps compare by time. An Icon, an Image and a Link sort by their text, as Text does: an icon, an image, a link and a text with the same text are equal. Custom values compare with GridValue::cmp_value, which keeps the order total.

Not the same as ==, which compares floats with f64::eq (a NaN is not equal to itself, -0.0 equals 0.0), compares decimals by value (1.0 equals 1.00) and never calls values of two variants equal.

Source

pub fn is_number(&self) -> bool

Returns true for numbers, which are right-aligned by default.

Trait Implementations§

Source§

impl<'a> Clone for CellValue<'a>

Source§

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

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<'a> Debug for CellValue<'a>

Source§

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

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

impl PartialEq for CellValue<'_>

Source§

fn eq(&self, other: &Self) -> 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<'a> Copy for CellValue<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for CellValue<'a>

§

impl<'a> !RefUnwindSafe for CellValue<'a>

§

impl<'a> Send for CellValue<'a>

§

impl<'a> Sync for CellValue<'a>

§

impl<'a> Unpin for CellValue<'a>

§

impl<'a> UnsafeUnpin for CellValue<'a>

§

impl<'a> !UnwindSafe for CellValue<'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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

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.
§

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.
§

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.
§

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.
§

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

§

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

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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