From 8d27a3bc26b662d7a93465a1c352df113b24d920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 11 Sep 2025 05:06:36 +0200 Subject: [PATCH] Leverage `&str` implementation of `Selector` for `String` --- selector/src/lib.rs | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/selector/src/lib.rs b/selector/src/lib.rs index b8081178..3d60a127 100644 --- a/selector/src/lib.rs +++ b/selector/src/lib.rs @@ -71,33 +71,11 @@ impl Selector for String { type Output = target::Text; fn select(&mut self, target: Target<'_>) -> Option { - match target { - Target::TextInput { - id, - bounds, - visible_bounds, - state, - } if state.text() == *self => Some(target::Text::Input { - id: id.cloned(), - bounds, - visible_bounds, - }), - Target::Text { - id, - bounds, - visible_bounds, - content, - } if content == *self => Some(target::Text::Raw { - id: id.cloned(), - bounds, - visible_bounds, - }), - _ => None, - } + self.as_str().select(target) } fn description(&self) -> String { - format!("text == \"{}\"", self.escape_default()) + self.as_str().description() } }