pub trait GridColumns:
Copy
+ Eq
+ Hash
+ Debug
+ Send
+ Sync
+ 'static {
// Required methods
fn all() -> &'static [Self];
fn id(self) -> &'static str;
fn ix(self) -> ColumnIx;
// Provided method
fn column_id(self) -> ColumnId { ... }
}Expand description
The set of columns of a row type, usually an application enum.
§Deriving
With the derive feature, #[derive(GridColumns)] writes this
implementation for an enum of unit variants. Declaration order is the
schema order, and a column’s id is its variant name in snake_case, as
a hand-written implementation spells it, so moving to the derive keeps
saved layouts. #[grid_column(id = "…")] sets one column’s id,
#[grid_columns(rename_all = "…")] the naming rule, and
#[grid_columns(crate = "…")] the path of a re-exported grid crate.
The derive refuses at compile time what a hand-written implementation
can get wrong: a variant missing from all(), an index shifted by an
explicit discriminant, a repeated id, more than 128 columns.
use gpui_kit_grid::GridColumns;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, GridColumns)]
enum TradeColumn {
Id,
Instrument,
BidSize, // "bid_size"
#[grid_column(id = "px")]
Price,
}
assert_eq!(TradeColumn::BidSize.id(), "bid_size");
assert_eq!(TradeColumn::Price.id(), "px");
assert_eq!(TradeColumn::Price.ix().get(), 3);Required Methods§
Provided Methods§
Sourcefn column_id(self) -> ColumnId
fn column_id(self) -> ColumnId
The column’s identifier as a ColumnId. Borrows GridColumns::id
without allocating.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.