summaryrefslogtreecommitdiffstats
path: root/test/src/selector.rs
blob: 54faa1a9517daea425bcdba31cb715f882bcc9fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::core::text;
use crate::core::widget;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Selector {
    Id(widget::Id),
    Text(text::Fragment<'static>),
}

impl From<widget::Id> for Selector {
    fn from(id: widget::Id) -> Self {
        Self::Id(id)
    }
}

impl From<&'static str> for Selector {
    fn from(id: &'static str) -> Self {
        Self::Id(widget::Id::new(id))
    }
}

pub fn text(fragment: impl text::IntoFragment<'static>) -> Selector {
    Selector::Text(fragment.into_fragment())
}