iced-yoda/core/src/widget/operation/search_id.rs
Votre Nom 8a7a32ff92
Some checks are pending
Audit / vulnerabilities (push) Waiting to run
Check / wasm (push) Waiting to run
Check / widget (push) Waiting to run
Document / all (push) Waiting to run
Format / all (push) Waiting to run
Lint / all (push) Waiting to run
Test / all (macOS-latest, 1.88) (push) Waiting to run
Test / all (macOS-latest, beta) (push) Waiting to run
Test / all (macOS-latest, stable) (push) Waiting to run
Test / all (ubuntu-latest, 1.88) (push) Waiting to run
Test / all (ubuntu-latest, beta) (push) Waiting to run
Test / all (ubuntu-latest, stable) (push) Waiting to run
Test / all (windows-latest, 1.88) (push) Waiting to run
Test / all (windows-latest, beta) (push) Waiting to run
Test / all (windows-latest, stable) (push) Waiting to run
yoda: cargo fix --lib across all crates — drop ~115 trivial warnings
Auto-applied suggestions (unused imports, _-prefixed unused params,
redundant mutability) on iced_core, iced_widget, iced_runtime, iced_winit,
iced_wgpu, iced_graphics, iced_tiny_skia. From 170 warnings down to 55.

Leyoda 2026 – GPLv3
2026-05-05 16:45:37 +02:00

49 lines
1 KiB
Rust

//! Search for widgets with the target Id.
use super::Operation;
use crate::{
Rectangle,
id::Id,
widget::operation::Outcome,
};
/// Produces an [`Operation`] that searches for the Id
pub fn search_id(target: Id) -> impl Operation<Id> {
struct Find {
found: bool,
target: Id,
}
impl Operation<Id> for Find {
fn custom(
&mut self,
id: Option<&Id>,
_bounds: Rectangle,
_state: &mut dyn std::any::Any,
) {
if Some(&self.target) == id {
self.found = true;
}
}
fn finish(&self) -> Outcome<Id> {
if self.found {
Outcome::Some(self.target.clone())
} else {
Outcome::None
}
}
fn traverse(
&mut self,
operate: &mut dyn FnMut(&mut dyn Operation<Id>),
) {
operate(self);
}
}
Find {
found: false,
target,
}
}