Skip to content

Instantly share code, notes, and snippets.

@alanwsmith
Created May 29, 2024 19:07
Show Gist options
  • Save alanwsmith/02a4d521b60d5b0a59264d8aff1a027f to your computer and use it in GitHub Desktop.
Save alanwsmith/02a4d521b60d5b0a59264d8aff1a027f to your computer and use it in GitHub Desktop.
pub fn parse(args: &[Value]) -> Option<PageFilterOrSet> {
// TODO: Error handling
let and_groups = args
.iter()
.filter_map(|ag| {
if let Ok(and_iter) = ag.try_iter() {
Some(PageFilterAndGroup {
filters: and_iter
.into_iter()
.filter_map(|filter_string| {
if let Some(text) = filter_string.as_str() {
PageFilter::parse(text)
} else {
None
}
})
.collect::<Vec<PageFilter>>(),
})
} else {
None
}
})
.collect();
Some(PageFilterOrSet { and_groups })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment