pub trait SimpleTransform<'a>: Iterator<Item = char> + Sized {
// Required method
fn transform_chars(chars: Chars<'a>) -> Self;
// Provided methods
fn will_modify(val: &str) -> bool { ... }
fn transform<'b, T: Into<Cow<'b, str>>>(s: T) -> Cow<'b, str> { ... }
}Expand description
A simple trait for in-place string transformations.
This trait allows character-iterator adaptors to modify strings in-place.
It is implemented by adaptors with a single required associated function,
transform_chars, for constructing the adaptor. In return, this trait
provides an associated function, transform, which can apply the
transformation to both owned strings and string slices, without allocating
when possible.
This trait is a simplified version of StringTransform. See the
documentation of that trait for more details.
Required Methods§
Sourcefn transform_chars(chars: Chars<'a>) -> Self
fn transform_chars(chars: Chars<'a>) -> Self
Transform the characters of a string.
Provided Methods§
Sourcefn will_modify(val: &str) -> bool
fn will_modify(val: &str) -> bool
A hint to short-circuit string transformations.
If true, the string might be modified by the transform. If false, the string will definitely not be modified by the transform.
Implementors may override this function to facilitate copy-on-write optimizations. The default implementation always returns true, which disables copy-on-write.
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.