Skip to main content

TextSlice

Trait TextSlice 

Source
pub trait TextSlice: Sealed {
    // Required method
    fn slice(&self, range: impl Ranged) -> &str;
}
Expand description

A slice of the source text.

Required Methods§

Source

fn slice(&self, range: impl Ranged) -> &str

Returns the slice of the text within the given range.

§Note

This is the same as &self[range] if self is a str and range a TextRange.

§Panics

If the range is out of bounds.

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 TextSlice for str

Source§

fn slice(&self, ranged: impl Ranged) -> &str

Implementors§