SplitableSpanCtx

Trait SplitableSpanCtx 

Source
pub trait SplitableSpanCtx: Clone {
    type Ctx: ?Sized;

    // Required method
    fn truncate_ctx(&mut self, at: usize, ctx: &Self::Ctx) -> Self;

    // Provided methods
    fn truncate_keeping_right_ctx(&mut self, at: usize, ctx: &Self::Ctx) -> Self { ... }
    fn split_ctx(self, at: usize, ctx: &Self::Ctx) -> (Self, Self) { ... }
}

Required Associated Types§

Required Methods§

Source

fn truncate_ctx(&mut self, at: usize, ctx: &Self::Ctx) -> Self

Split the entry, returning the part of the entry which was jettisoned. After truncating at pos, self.len() == pos and the returned value contains the rest of the items.

let initial_len = entry.len();
let rest = entry.truncate(truncate_at);
assert!(initial_len == truncate_at + rest.len());

at parameter must strictly obey 0 < at < entry.len()

Provided Methods§

Source

fn truncate_keeping_right_ctx(&mut self, at: usize, ctx: &Self::Ctx) -> Self

The inverse of truncate. This method mutably truncates an item, keeping all content from at..item.len() and returning the item range from 0..at.

Source

fn split_ctx(self, at: usize, ctx: &Self::Ctx) -> (Self, Self)

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<T, E> SplitableSpanCtx for Result<T, E>
where T: SplitableSpanCtx + Clone, E: Clone,

Source§

type Ctx = <T as SplitableSpanCtx>::Ctx

Source§

fn truncate_ctx(&mut self, at: usize, ctx: &Self::Ctx) -> Self

Implementors§