Change From<str> for Selector to Text in iced_test

This commit is contained in:
Héctor Ramón Jiménez 2025-05-28 03:25:39 +02:00
parent 03326b955b
commit f929a20d29
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 21 additions and 11 deletions

View file

@ -18,12 +18,17 @@ impl From<widget::Id> for Selector {
}
impl From<&'static str> for Selector {
fn from(id: &'static str) -> Self {
Self::Id(widget::Id::new(id))
fn from(text: &'static str) -> Self {
Self::Text(text.into())
}
}
/// Creates [`Selector`] that finds the widget containing the given text fragment.
/// Creates a [`Selector`] that finds the widget with the given [`widget::Id`].
pub fn id(id: impl Into<widget::Id>) -> Selector {
Selector::Id(id.into())
}
/// Creates a [`Selector`] that finds the widget containing the given text fragment.
pub fn text(fragment: impl text::IntoFragment<'static>) -> Selector {
Selector::Text(fragment.into_fragment())
}