pub struct MetaVarEnv<'tree, D>where
D: Doc,{ /* private fields */ }Expand description
a dictionary that stores metavariable instantiation const a = 123 matched with const a = $A will produce env: $A => 123
Implementations§
Source§impl<'t, D> MetaVarEnv<'t, D>where
D: Doc,
impl<'t, D> MetaVarEnv<'t, D>where
D: Doc,
pub fn new() -> MetaVarEnv<'t, D>
pub fn insert( &mut self, id: &str, ret: Node<'t, D>, ) -> Option<&mut MetaVarEnv<'t, D>>
pub fn insert_multi( &mut self, id: &str, ret: Vec<Node<'t, D>>, ) -> Option<&mut MetaVarEnv<'t, D>>
Sourcepub fn insert_owned(
&mut self,
id: Arc<str>,
ret: Node<'t, D>,
) -> Option<&mut MetaVarEnv<'t, D>>
pub fn insert_owned( &mut self, id: Arc<str>, ret: Node<'t, D>, ) -> Option<&mut MetaVarEnv<'t, D>>
Insert without cloning the key if it’s already owned
Sourcepub fn insert_multi_owned(
&mut self,
id: Arc<str>,
ret: Vec<Node<'t, D>>,
) -> Option<&mut MetaVarEnv<'t, D>>
pub fn insert_multi_owned( &mut self, id: Arc<str>, ret: Vec<Node<'t, D>>, ) -> Option<&mut MetaVarEnv<'t, D>>
Insert multi without cloning the key if it’s already owned
pub fn get_match(&self, var: &str) -> Option<&Node<'t, D>>
pub fn get_multiple_matches(&self, var: &str) -> Vec<Node<'t, D>>
Sourcepub fn get_multiple_matches_ref(&self, var: &str) -> Option<&Vec<Node<'t, D>>>
pub fn get_multiple_matches_ref(&self, var: &str) -> Option<&Vec<Node<'t, D>>>
Returns a reference to multiple matches without cloning
pub fn add_label(&mut self, label: &str, node: Node<'t, D>)
pub fn get_labels(&self, label: &str) -> Option<&Vec<Node<'t, D>>>
pub fn get_matched_variables( &self, ) -> impl Iterator<Item = MetaVariable> + use<'_, 't, D>
pub fn match_constraints<M>(
&mut self,
var_matchers: &HashMap<Arc<str>, M, RandomState<rapidhash::::fast::RandomState::{constant#0}, rapidhash::::fast::RandomState::{constant#1}, rapidhash::::fast::RandomState::{constant#2}, rapidhash::::fast::RandomState::{constant#3}>>,
) -> boolwhere
M: Matcher,
pub fn insert_transformation( &mut self, var: &MetaVariable, name: &str, slice: Vec<<<D as Doc>::Source as Content>::Underlying>, )
pub fn get_transformed( &self, var: &str, ) -> Option<&Vec<<<D as Doc>::Source as Content>::Underlying>>
pub fn get_var_bytes<'s>( &'s self, var: &MetaVariable, ) -> Option<&'s [<<D as Doc>::Source as Content>::Underlying]>
Trait Implementations§
Source§impl<'tree, D> Clone for MetaVarEnv<'tree, D>
impl<'tree, D> Clone for MetaVarEnv<'tree, D>
Source§fn clone(&self) -> MetaVarEnv<'tree, D>
fn clone(&self) -> MetaVarEnv<'tree, D>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'tree, D> Debug for MetaVarEnv<'tree, D>
impl<'tree, D> Debug for MetaVarEnv<'tree, D>
Source§impl<D> Default for MetaVarEnv<'_, D>where
D: Doc,
impl<D> Default for MetaVarEnv<'_, D>where
D: Doc,
Source§fn default() -> MetaVarEnv<'_, D>
fn default() -> MetaVarEnv<'_, D>
Returns the “default value” for a type. Read more
Source§impl<'tree, D> From<MetaVarEnv<'tree, D>> for HashMap<String, String, RandomState<rapidhash::::fast::RandomState::{constant#0}, rapidhash::::fast::RandomState::{constant#1}, rapidhash::::fast::RandomState::{constant#2}, rapidhash::::fast::RandomState::{constant#3}>>
impl<'tree, D> From<MetaVarEnv<'tree, D>> for HashMap<String, String, RandomState<rapidhash::::fast::RandomState::{constant#0}, rapidhash::::fast::RandomState::{constant#1}, rapidhash::::fast::RandomState::{constant#2}, rapidhash::::fast::RandomState::{constant#3}>>
Source§fn from(
env: MetaVarEnv<'tree, D>,
) -> HashMap<String, String, RandomState<rapidhash::::fast::RandomState::{constant#0}, rapidhash::::fast::RandomState::{constant#1}, rapidhash::::fast::RandomState::{constant#2}, rapidhash::::fast::RandomState::{constant#3}>>
fn from( env: MetaVarEnv<'tree, D>, ) -> HashMap<String, String, RandomState<rapidhash::::fast::RandomState::{constant#0}, rapidhash::::fast::RandomState::{constant#1}, rapidhash::::fast::RandomState::{constant#2}, rapidhash::::fast::RandomState::{constant#3}>>
Converts to this type from the input type.
Auto Trait Implementations§
impl<'tree, D> Freeze for MetaVarEnv<'tree, D>
impl<'tree, D> RefUnwindSafe for MetaVarEnv<'tree, D>where
<D as Doc>::Node<'tree>: RefUnwindSafe,
D: RefUnwindSafe,
<<D as Doc>::Source as Content>::Underlying: RefUnwindSafe,
impl<'tree, D> Send for MetaVarEnv<'tree, D>
impl<'tree, D> Sync for MetaVarEnv<'tree, D>
impl<'tree, D> Unpin for MetaVarEnv<'tree, D>
impl<'tree, D> UnsafeUnpin for MetaVarEnv<'tree, D>
impl<'tree, D> UnwindSafe for MetaVarEnv<'tree, D>where
<D as Doc>::Node<'tree>: UnwindSafe,
D: RefUnwindSafe,
<<D as Doc>::Source as Content>::Underlying: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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