docs(core): add documentation for all public API members
This commit is contained in:
parent
ee75539d73
commit
299e572186
9 changed files with 325 additions and 48 deletions
|
|
@ -1,3 +1,5 @@
|
|||
//! Iterators for expression trees
|
||||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use super::{Expr, ExprRef};
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ internal_macros::forward_box_binop! {impl Div, div for NumExpr, NumExpr }
|
|||
use super::Ordering;
|
||||
|
||||
impl NumExpr {
|
||||
/// Convenience method to create an `lhs < rhs` expression.
|
||||
pub fn less_than(self, rhs: Self) -> BoolExpr {
|
||||
BoolExpr::Cmp {
|
||||
op: Ordering::Less { strict: true },
|
||||
|
|
@ -98,6 +99,7 @@ impl NumExpr {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convenience method to create an `lhs <= rhs` expression.
|
||||
pub fn less_than_eq(self, rhs: Self) -> BoolExpr {
|
||||
BoolExpr::Cmp {
|
||||
op: Ordering::Less { strict: false },
|
||||
|
|
@ -106,6 +108,7 @@ impl NumExpr {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convenience method to create an `lhs > rhs` expression.
|
||||
pub fn greater_than(self, rhs: Self) -> BoolExpr {
|
||||
BoolExpr::Cmp {
|
||||
op: Ordering::Greater { strict: true },
|
||||
|
|
@ -114,6 +117,7 @@ impl NumExpr {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convenience method to create an `lhs >= rhs` expression.
|
||||
pub fn greater_than_eq(self, rhs: Self) -> BoolExpr {
|
||||
BoolExpr::Cmp {
|
||||
op: Ordering::Greater { strict: false },
|
||||
|
|
@ -122,6 +126,7 @@ impl NumExpr {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convenience method to create an `lhs == rhs` expression.
|
||||
pub fn equal(self, rhs: Self) -> BoolExpr {
|
||||
BoolExpr::Cmp {
|
||||
op: Ordering::Eq,
|
||||
|
|
@ -130,6 +135,7 @@ impl NumExpr {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convenience method to create an `lhs != rhs` expression.
|
||||
pub fn not_equal(self, rhs: Self) -> BoolExpr {
|
||||
BoolExpr::Cmp {
|
||||
op: Ordering::NotEq,
|
||||
|
|
|
|||
|
|
@ -5,17 +5,25 @@ use super::ExprRef;
|
|||
|
||||
/// A trait representing expressions
|
||||
pub trait Expr {
|
||||
/// Check if the given expression is a numeric expression
|
||||
fn is_numeric(&self) -> bool;
|
||||
/// Check if the given expression is a boolean expression
|
||||
fn is_boolean(&self) -> bool;
|
||||
|
||||
/// Get the arguments to the current expression.
|
||||
///
|
||||
/// If the expression doesn't contain arguments (i.e., it is a leaf expression) then
|
||||
/// the vector is empty.
|
||||
fn args(&self) -> Vec<ExprRef<'_>>;
|
||||
|
||||
/// Helper function for upcasting to [`std::any::Any`] and then downcasting to a
|
||||
/// concrete [`BoolExpr`](crate::expr::BoolExpr) or
|
||||
/// [`NumExpr`](crate::expr::NumExpr).
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
||||
/// An iterator over the AST starting from the current expression.
|
||||
fn iter(&self) -> AstIter<'_>;
|
||||
}
|
||||
|
||||
impl dyn Expr {
|
||||
/// Convenience method to downcast an expression to a concrete expression node.
|
||||
pub fn downcast_expr_ref<T>(&self) -> Option<&T>
|
||||
where
|
||||
T: Any,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue