[−][src]Struct line_span::LineSpan
LineSpan
represents a single line, excluding \n
and \r\n
.
use line_span::LineSpans; let text = "foo\nbar\r\nbaz"; for span in text.line_spans() { println!("{:>2?}: {:?}", span.range(), span.as_str()); }
This will output the following:
0.. 3: "foo"
4.. 7: "bar"
9..12: "baz"
Methods
impl<'a> LineSpan<'a>
[src]
pub fn start(&self) -> usize
[src]
Returns the byte index of the start of the line.
pub fn end(&self) -> usize
[src]
Returns the byte index of the end of the line.
pub fn range(&self) -> Range<usize>
[src]
Returns the byte index range of the start and end of the line.
pub fn as_str(&self) -> &'a str
[src]
Returns &str
of the line, excluding \n
and \r\n
.
Trait Implementations
impl<'a> Clone for LineSpan<'a>
[src]
impl<'a> Copy for LineSpan<'a>
[src]
impl<'a> Debug for LineSpan<'a>
[src]
impl<'a> Deref for LineSpan<'a>
[src]
type Target = str
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
Returns as_str
.
impl<'a> Display for LineSpan<'a>
[src]
impl<'a> Eq for LineSpan<'a>
[src]
impl<'a> From<LineSpan<'a>> for &'a str
[src]
impl<'a> From<LineSpan<'a>> for Range<usize>
[src]
impl<'a> PartialEq<LineSpan<'a>> for LineSpan<'a>
[src]
impl<'a> StructuralEq for LineSpan<'a>
[src]
impl<'a> StructuralPartialEq for LineSpan<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for LineSpan<'a>
impl<'a> Send for LineSpan<'a>
impl<'a> Sync for LineSpan<'a>
impl<'a> Unpin for LineSpan<'a>
impl<'a> UnwindSafe for LineSpan<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,