pub struct ExpressionReferences<'expr> { /* private fields */ }
Expand description
A collection of all the references that an expression makes to variables and functions.
Implementations§
Source§impl ExpressionReferences<'_>
impl ExpressionReferences<'_>
Sourcepub fn has_variable(&self, name: impl AsRef<str>) -> bool
pub fn has_variable(&self, name: impl AsRef<str>) -> bool
Returns true if the expression references the provided variable name.
§Example
let expression = Parser::new().parse("foo.bar == true").unwrap();
let references = expression.references();
assert!(references.has_variable("foo"));
Sourcepub fn has_function(&self, name: impl AsRef<str>) -> bool
pub fn has_function(&self, name: impl AsRef<str>) -> bool
Returns true if the expression references the provided function name.
§Example
let expression = Parser::new().parse("size(foo) > 0").unwrap();
let references = expression.references();
assert!(references.has_function("size"));
Sourcepub fn variables(&self) -> Vec<&str>
pub fn variables(&self) -> Vec<&str>
Returns a list of all variables referenced in the expression.
§Example
let expression = Parser::new().parse("foo.bar == true").unwrap();
let references = expression.references();
assert_eq!(vec!["foo"], references.variables());
Sourcepub fn functions(&self) -> Vec<&str>
pub fn functions(&self) -> Vec<&str>
Returns a list of all functions referenced in the expression.
§Example
let expression = Parser::new().parse("size(foo) > 0").unwrap();
let references = expression.references();
assert!(references.functions().contains(&"_>_"));
assert!(references.functions().contains(&"size"));
Auto Trait Implementations§
impl<'expr> Freeze for ExpressionReferences<'expr>
impl<'expr> RefUnwindSafe for ExpressionReferences<'expr>
impl<'expr> Send for ExpressionReferences<'expr>
impl<'expr> Sync for ExpressionReferences<'expr>
impl<'expr> Unpin for ExpressionReferences<'expr>
impl<'expr> UnwindSafe for ExpressionReferences<'expr>
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
Attempts to downcast this to
T
behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
Attempts to downcast this to
T
behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
Attempts to downcast this to
T
behind Rc
pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
Attempts to downcast this to
T
behind Arc
pointerSource§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