Struct Variable

Source
pub struct Variable { /* private fields */ }

Implementations§

Source§

impl Variable

Source

pub fn new(scope: usize, index: usize) -> Self

Create a variable, where we already know the scope and index it will be bound to

Source

pub fn new_dynamic(name: &str) -> Self

Create a dynamic variable, which will be bound to the first scope that uses it

Warning: this is not stable or tested yet. This implementation is still incomplete.

Source

pub fn try_scope(&self) -> GritResult<u16>

Try to get the scope of the variable, if it has been bound to a scope. If the variable has not been bound to a scope, return an error. When possible, prefer to use get_scope() instead, which will initialize the variable’s scope if it is not already bound.

Source

pub fn try_index(&self) -> GritResult<u16>

Try to get the index of the variable, if it has been bound to an index. If the variable has not been bound to an index, return an error. When possible, prefer to use get_index() instead, which will initialize the variable’s index if it is not already bound.

Source

pub fn get_scope<Q: QueryContext>( &self, state: &mut State<'_, Q>, ) -> GritResult<u16>

Get the scope of the variable, initializing it if it is not already bound.

Source

pub fn get_index<Q: QueryContext>( &self, state: &mut State<'_, Q>, ) -> GritResult<u16>

Get the index of the variable, initializing it if it is not already bound.

Source

pub fn get_pattern_or_resolved<'a, 'b, Q: QueryContext>( &self, state: &'b State<'a, Q>, ) -> GritResult<Option<PatternOrResolved<'a, 'b, Q>>>

Source

pub fn get_pattern_or_resolved_mut<'a, 'b, Q: QueryContext>( &self, state: &'b mut State<'a, Q>, ) -> GritResult<Option<PatternOrResolvedMut<'a, 'b, Q>>>

Source

pub fn file_name() -> Self

Source

pub fn is_file_name(&self) -> bool

Source

pub fn is_program(&self) -> bool

Source

pub fn is_probably_match(&self) -> bool

We auto-insert a $match variable during auto-wrap, which we can usually treat as being usable in the program body

Source

pub fn text<'a, Q: QueryContext>( &self, state: &State<'a, Q>, lang: &Q::Language<'a>, ) -> GritResult<Cow<'a, str>>

Trait Implementations§

Source§

impl Clone for Variable

Source§

fn clone(&self) -> Variable

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Variable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Q: QueryContext> Matcher<Q> for Variable

Source§

fn execute<'a>( &'a self, resolved_pattern: &Q::ResolvedPattern<'a>, state: &mut State<'a, Q>, context: &'a Q::ExecContext<'a>, logs: &mut AnalysisLogs, ) -> GritResult<bool>

Source§

impl PatternName for Variable

Source§

fn name(&self) -> &'static str

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V