1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
use crate::record::StudyRecord; use std::collections::HashSet; use structopt::StructOpt; #[derive(Debug, StructOpt)] pub struct SelectOpt { #[structopt(long)] pub problems: Vec<String>, } impl SelectOpt { pub fn build(&self) -> Selector { Selector { problems: self.problems.iter().cloned().collect(), } } } #[derive(Debug)] pub struct Selector { problems: HashSet<String>, } impl Selector { pub fn is_selected(&self, study: &StudyRecord) -> bool { if !self.problems.is_empty() && !self.problems.contains(&study.problem.spec.name) { return false; } true } }