pub trait StrInfo<'a>: Sized {
type Context: Default;
// Required method
fn generate(_: &mut Self::Context, _: &'a str) -> Self;
}Expand description
The trait for the elements yielded by the crate::StrSplitter
§Example
use splitter::StrInfo;
#[derive(Default)]
struct SpanCtx(usize);
struct Span {
start: usize,
end: usize,
}
impl<'a> StrInfo<'a> for Span {
type Context = SpanCtx;
fn generate(ctx: &mut Self::Context, ts: &'a str) -> Self {
let start = ctx.0;
ctx.0 += ts.len();
Self { start, end: ctx.0 }
}
}Required Associated Types§
Required Methods§
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.