[][src]Struct c2rust_refactor::matcher::MatchCtxt

pub struct MatchCtxt<'a, 'tcx: 'a> {
    pub bindings: Bindings,
    pub types: BindingTypes,
    pub debug: bool,
    // some fields omitted
}

Pattern-matching context. Stores configuration that affects pattern matching behavior, and collects bindings captured during the match.

Fields

bindings: Bindingstypes: BindingTypesdebug: bool

Methods

impl<'a, 'tcx> MatchCtxt<'a, 'tcx>[src]

pub fn new(
    st: &'a CommandState,
    cx: &'a RefactorCtxt<'a, 'tcx>
) -> MatchCtxt<'a, 'tcx>
[src]

pub fn parse_expr(&mut self, src: &str) -> P<Expr>[src]

pub fn parse_pat(&mut self, src: &str) -> P<Pat>[src]

pub fn parse_ty(&mut self, src: &str) -> P<Ty>[src]

pub fn parse_stmts(&mut self, src: &str) -> Vec<Stmt>[src]

pub fn parse_items(&mut self, src: &str) -> Vec<P<Item>>[src]

pub fn try_match<T: TryMatch>(&mut self, pat: &T, target: &T) -> Result<()>[src]

Try to match target against pat, updating self.bindings with the results.

pub fn from_match<T: TryMatch>(
    st: &'a CommandState,
    cx: &'a RefactorCtxt<'a, 'tcx>,
    pat: &T,
    target: &T
) -> Result<MatchCtxt<'a, 'tcx>>
[src]

Build a new MatchCtxt, and try to match target against pat in that context.

pub fn clone_match<T: TryMatch>(
    &self,
    pat: &T,
    target: &T
) -> Result<MatchCtxt<'a, 'tcx>>
[src]

Clone this context and try to perform a match in the clone, returning Ok if it succeeds.

pub fn set_type<S: IntoSymbol>(&mut self, name: S, ty: BindingType)[src]

pub fn maybe_capture_ident(
    &mut self,
    pattern: &Ident,
    target: &Ident
) -> Result<bool>
[src]

Try to capture an ident. Returns Ok(true) if it captured, Ok(false) if pattern is not a capturing pattern, or Err(_) if capturing failed.

pub fn maybe_capture_label(
    &mut self,
    pattern: &Label,
    target: &Label
) -> Result<bool>
[src]

pub fn maybe_capture_path(
    &mut self,
    pattern: &Path,
    target: &Path
) -> Result<bool>
[src]

pub fn maybe_capture_expr(
    &mut self,
    pattern: &Expr,
    target: &Expr
) -> Result<bool>
[src]

pub fn maybe_capture_pat(&mut self, pattern: &Pat, target: &Pat) -> Result<bool>[src]

pub fn maybe_capture_ty(&mut self, pattern: &Ty, target: &Ty) -> Result<bool>[src]

pub fn maybe_capture_stmt(
    &mut self,
    pattern: &Stmt,
    target: &Stmt
) -> Result<bool>
[src]

pub fn do_marked<T, F>(
    &mut self,
    tts: &TokenStream,
    func: F,
    target: &T
) -> Result<()> where
    T: TryMatch + GetNodeId,
    F: for<'b> FnOnce(&mut Parser<'b>) -> PResult<'b, T>, 
[src]

Handle the marked!(...) matching form.

pub fn do_def_expr(&mut self, tts: &TokenStream, target: &Expr) -> Result<()>[src]

Handle the def!(...) matching form for exprs.

pub fn do_def_ty(&mut self, tts: &TokenStream, target: &Ty) -> Result<()>[src]

Handle the def!(...) matching form for exprs.

pub fn do_typed<T, F>(
    &mut self,
    tts: &TokenStream,
    func: F,
    target: &T
) -> Result<()> where
    T: TryMatch + GetNodeId,
    F: for<'b> FnOnce(&mut Parser<'b>) -> PResult<'b, T>, 
[src]

Handle the typed!(...) matching form.

pub fn do_cast<F>(
    &mut self,
    tts: &TokenStream,
    func: F,
    target: &Expr
) -> Result<()> where
    F: for<'b> FnOnce(&mut Parser<'b>) -> PResult<'b, P<Expr>>, 
[src]

Trait Implementations

impl<'a, 'tcx: 'a> Clone for MatchCtxt<'a, 'tcx>[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<'a, 'tcx> !Send for MatchCtxt<'a, 'tcx>

impl<'a, 'tcx> !Sync for MatchCtxt<'a, 'tcx>

Blanket Implementations

impl<T> Lone for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<E> SpecializationError for E[src]

impl<T> Erased for T[src]

impl<T> Send for T where
    T: ?Sized
[src]

impl<T> Sync for T where
    T: ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self

impl<T> MaybeResult for T[src]

impl<'a, T> Captures for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> Make for T[src]

impl<T> Slottable for T[src]