pub struct Selector<T, S> {
pub identifier: Identifier<T, S>,
pub validator: fn(&S) -> bool,
/* private fields */
}Fields§
§identifier: Identifier<T, S>§validator: fn(&S) -> boolImplementations§
Source§impl<T, S: Selection> Selector<T, S>
impl<T, S: Selection> Selector<T, S>
Sourcepub fn new(identifier: Identifier<T, S>) -> Self
pub fn new(identifier: Identifier<T, S>) -> Self
Examples found in repository?
More examples
examples/basic.rs (line 10)
5async fn main() -> Result<()> {
6 let items = vec!["item1", "item2", "item3"];
7
8 let worker = Worker::new_single_column();
9 worker.append(items);
10 let selector = Selector::new(Indexed::identifier);
11 let mm = Matchmaker::new(worker, selector);
12
13 match mm.pick_default().await {
14 Ok(v) => {
15 println!("{}", v[0]);
16 }
17 Err(err) => match err {
18 MatchError::Abort(1) => {
19 eprintln!("cancelled");
20 }
21 _ => {
22 eprintln!("Error: {err}");
23 }
24 },
25 }
26
27 Ok(())
28}pub fn new_with_validator( identifier: Identifier<T, S>, validator: fn(&S) -> bool, ) -> Self
pub fn sel(&mut self, item: &T) -> bool
pub fn desel(&mut self, item: &T) -> bool
pub fn contains(&self, item: &T) -> bool
pub fn toggle(&mut self, item: &T)
pub fn clear(&mut self)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn output(&mut self) -> impl Iterator<Item = S>
pub fn identify_to_vec<I>(&self, items: I) -> Vec<S>
pub fn map_to_vec<U, F>(&self, f: F) -> Vec<U>
pub fn revalidate(&mut self)
pub fn cycle_all_bg<I>(&self, items: I)
Trait Implementations§
Auto Trait Implementations§
impl<T, S> Freeze for Selector<T, S>
impl<T, S> RefUnwindSafe for Selector<T, S>
impl<T, S> Send for Selector<T, S>where
S: Send,
impl<T, S> Sync for Selector<T, S>where
S: Send,
impl<T, S> Unpin for Selector<T, S>
impl<T, S> UnwindSafe for Selector<T, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaybeExt for T
impl<T> MaybeExt for T
Source§fn maybe_take(&mut self, maybe: Option<T>)
fn maybe_take(&mut self, maybe: Option<T>)
Merge from maybe by taking.
Source§fn maybe_clone(&mut self, maybe: &Option<T>)where
T: Clone,
fn maybe_clone(&mut self, maybe: &Option<T>)where
T: Clone,
Merge from maybe by cloning.