pub enum Ast {
And(Vec<Ast>),
Or(Vec<Ast>),
Constraint(Constraint),
}Expand description
Raw AST — unvalidated, produced directly by the parser.
Variants§
Implementations§
Source§impl Ast
impl Ast
Sourcepub fn and(nodes: impl IntoIterator<Item = Ast>) -> Ast
pub fn and(nodes: impl IntoIterator<Item = Ast>) -> Ast
Combines nodes with AND. Panics if nodes is empty; unwraps if single element.
Sourcepub fn or(nodes: impl IntoIterator<Item = Ast>) -> Ast
pub fn or(nodes: impl IntoIterator<Item = Ast>) -> Ast
Combines nodes with OR. Panics if nodes is empty; unwraps if single element.
Sourcepub fn try_and(nodes: impl IntoIterator<Item = Ast>) -> Option<Ast>
pub fn try_and(nodes: impl IntoIterator<Item = Ast>) -> Option<Ast>
Like and, but returns None for an empty iterator.
Sourcepub fn try_or(nodes: impl IntoIterator<Item = Ast>) -> Option<Ast>
pub fn try_or(nodes: impl IntoIterator<Item = Ast>) -> Option<Ast>
Like try_or, but returns None for an empty iterator.
Sourcepub fn try_and_opts(nodes: impl IntoIterator<Item = Option<Ast>>) -> Option<Ast>
pub fn try_and_opts(nodes: impl IntoIterator<Item = Option<Ast>>) -> Option<Ast>
Like try_and, but accepts optional nodes — None entries are silently skipped.
Useful when building a filter from a mix of optional query parameters:
use rest_sql::{Ast, filter::{eq, gte}};
let ast = Ast::try_and_opts([
Some(eq("genre", "Drama")),
None, // absent query param — skipped
Some(gte("year", 2000i64)),
]);
// equivalent to: Some(eq("genre", "Drama") & gte("year", 2000))Sourcepub fn try_or_opts(nodes: impl IntoIterator<Item = Option<Ast>>) -> Option<Ast>
pub fn try_or_opts(nodes: impl IntoIterator<Item = Option<Ast>>) -> Option<Ast>
Like try_or, but accepts optional nodes — None entries are silently skipped.
Trait Implementations§
Source§impl BitAnd for Ast
And & And → flat And; And & other → appends to the And list; otherwise wraps in a new And.
impl BitAnd for Ast
And & And → flat And; And & other → appends to the And list; otherwise wraps in a new And.
Source§impl BitOr for Ast
Or | Or → flat Or; Or | other → appends to the Or list; otherwise wraps in a new Or.
impl BitOr for Ast
Or | Or → flat Or; Or | other → appends to the Or list; otherwise wraps in a new Or.
impl StructuralPartialEq for Ast
Auto Trait Implementations§
impl Freeze for Ast
impl RefUnwindSafe for Ast
impl Send for Ast
impl Sync for Ast
impl Unpin for Ast
impl UnsafeUnpin for Ast
impl UnwindSafe for Ast
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