Skip to main content

SelectValue

Trait SelectValue 

Source
pub trait SelectValue:
    Clone
    + PartialEq
    + 'static {
    // Required method
    fn key(&self) -> SharedString;
}
Expand description

The value of a SelectItem: the item’s identity in the menu.

The key names the row’s element id, so it is stable across frames and unique in the menu. Strings and integers are values already; an application’s own enum or record implements this with its id.

use gpui_cn::SelectValue;
use gpui_kit::SharedString;

#[derive(Clone, PartialEq)]
enum Effort {
    Low,
    High,
}

impl SelectValue for Effort {
    fn key(&self) -> SharedString {
        match self {
            Self::Low => "low".into(),
            Self::High => "high".into(),
        }
    }
}

Required Methods§

Source

fn key(&self) -> SharedString

The stable name of the value’s row.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SelectValue for &'static str

Source§

impl SelectValue for SharedString

Source§

impl SelectValue for String

Source§

impl SelectValue for i32

Source§

impl SelectValue for i64

Source§

impl SelectValue for u32

Source§

impl SelectValue for u64

Source§

impl SelectValue for usize

Implementors§