pub struct PatternInferrer { /* private fields */ }Expand description
The pattern inference engine.
Given one or more before/after example pairs, the inferrer derives a
Pattern that captures the transformation.
Implementations§
Source§impl PatternInferrer
impl PatternInferrer
Sourcepub fn new(language: Box<dyn LanguageAdapter>) -> Self
pub fn new(language: Box<dyn LanguageAdapter>) -> Self
Creates a new inferrer backed by the given language adapter.
Sourcepub fn infer_from_example(&self, before: &str, after: &str) -> Result<Pattern>
pub fn infer_from_example(&self, before: &str, after: &str) -> Result<Pattern>
Infer a pattern from a single before/after example pair.
§Errors
Returns CodemodError::PatternInference if the ASTs cannot be
compared or no meaningful pattern can be derived.
Sourcepub fn infer_from_examples(
&self,
examples: &[(String, String)],
) -> Result<Pattern>
pub fn infer_from_examples( &self, examples: &[(String, String)], ) -> Result<Pattern>
Infer a pattern from multiple before/after example pairs.
The algorithm infers a pattern from the first pair and then validates it against subsequent pairs, refining the confidence score.
§Errors
Returns CodemodError::PatternInference if no consistent pattern
can be derived across the supplied examples.
Auto Trait Implementations§
impl Freeze for PatternInferrer
impl !RefUnwindSafe for PatternInferrer
impl Send for PatternInferrer
impl Sync for PatternInferrer
impl Unpin for PatternInferrer
impl UnsafeUnpin for PatternInferrer
impl !UnwindSafe for PatternInferrer
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> 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