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
30
31
32
33
34
35
36
37
use super::Expr;
/// A string prefix-match expression: `starts_with(expr, prefix)`.
///
/// Returns `true` if `expr` starts with `prefix`. The attribute reference
/// is always `expr` (lhs) and the prefix value is always `prefix` (rhs).
///
/// # Examples
///
/// ```text
/// starts_with(name, "Al") // true if name starts with "Al"
/// ```
#[derive(Debug, Clone, PartialEq)]
pub struct ExprStartsWith {
/// The attribute to test.
pub expr: Box<Expr>,
/// The prefix value to match against.
pub prefix: Box<Expr>,
}
impl Expr {
/// Creates a `starts_with(expr, prefix)` expression.
pub fn starts_with(expr: impl Into<Self>, prefix: impl Into<Self>) -> Self {
ExprStartsWith {
expr: Box::new(expr.into()),
prefix: Box::new(prefix.into()),
}
.into()
}
}
impl From<ExprStartsWith> for Expr {
fn from(value: ExprStartsWith) -> Self {
Self::StartsWith(value)
}
}