StrInfo

Trait StrInfo 

Source
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§

Source

type Context: Default

The needed Context for the StrInfo, to generate the correct values

Required Methods§

Source

fn generate(_: &mut Self::Context, _: &'a str) -> Self

Generates the StrInfo, based on the provided context an slice

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<'a> StrInfo<'a> for &'a str

Source§

type Context = ()

Source§

fn generate(_: &mut Self::Context, ts: &'a str) -> Self

Source§

impl<'a> StrInfo<'a> for String

Source§

type Context = ()

Source§

fn generate(_: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a> StrInfo<'a> for PhantomPinned

Source§

type Context = ()

Source§

fn generate(_: &mut Self::Context, _: &'a str) -> Self

Source§

impl<'a> StrInfo<'a> for Range<usize>

Source§

type Context = RangeCtx

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a> StrInfo<'a> for RangeInclusive<usize>

Source§

type Context = RangeCtx

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a> StrInfo<'a> for PathBuf

Source§

type Context = ()

Source§

fn generate(_: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T> StrInfo<'a> for PhantomData<T>

Source§

type Context = ()

Source§

fn generate(_: &mut Self::Context, _: &'a str) -> Self

Source§

impl<'a, T> StrInfo<'a> for Pin<T>
where T: StrInfo<'a> + Deref, T::Target: Unpin,

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T: StrInfo<'a>> StrInfo<'a> for Box<T>

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T: StrInfo<'a>> StrInfo<'a> for Rc<T>

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T: StrInfo<'a>> StrInfo<'a> for Arc<T>

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T: StrInfo<'a>> StrInfo<'a> for Cell<T>

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T: StrInfo<'a>> StrInfo<'a> for RefCell<T>

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T: StrInfo<'a>> StrInfo<'a> for UnsafeCell<T>

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T: StrInfo<'a>> StrInfo<'a> for ManuallyDrop<T>

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T: StrInfo<'a>> StrInfo<'a> for Mutex<T>

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Source§

impl<'a, T: StrInfo<'a>> StrInfo<'a> for RwLock<T>

Source§

type Context = WrapperCtx<'a, T>

Source§

fn generate(ctx: &mut Self::Context, s: &'a str) -> Self

Implementors§

Source§

impl<'a> StrInfo<'a> for Pos

Source§

type Context = PosCtx

Source§

impl<'a> StrInfo<'a> for Span

Source§

type Context = SpanCtx