ast_grep_core::replacer

Trait Replacer

Source
pub trait Replacer<D: Doc> {
    // Required method
    fn generate_replacement(
        &self,
        nm: &NodeMatch<'_, D>,
    ) -> Vec<<D::Source as Content>::Underlying>;

    // Provided method
    fn get_replaced_range(
        &self,
        nm: &NodeMatch<'_, D>,
        matcher: impl Matcher<D::Lang>,
    ) -> Range<usize> { ... }
}
Expand description

Replace meta variable in the replacer string

Required Methods§

Source

fn generate_replacement( &self, nm: &NodeMatch<'_, D>, ) -> Vec<<D::Source as Content>::Underlying>

Provided Methods§

Source

fn get_replaced_range( &self, nm: &NodeMatch<'_, D>, matcher: impl Matcher<D::Lang>, ) -> Range<usize>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<D, T> Replacer<D> for &T
where D: Doc, T: Replacer<D> + ?Sized,

Source§

fn generate_replacement( &self, nm: &NodeMatch<'_, D>, ) -> Vec<<D::Source as Content>::Underlying>

Source§

impl<D: Doc> Replacer<D> for str

Source§

fn generate_replacement( &self, nm: &NodeMatch<'_, D>, ) -> Vec<<D::Source as Content>::Underlying>

Implementors§

Source§

impl<'a, D: Doc> Replacer<D> for Node<'a, D>

Source§

impl<D: Doc> Replacer<D> for TemplateFix