pub struct LineTerminator(/* private fields */);
Expand description

A line terminator.

A line terminator represents the end of a line. Generally, every line is either “terminated” by the end of a stream or a specific byte (or sequence of bytes).

Generally, a line terminator is a single byte, specifically, \n, on Unix-like systems. On Windows, a line terminator is \r\n (referred to as CRLF for Carriage Return; Line Feed).

The default line terminator is \n on all platforms.

Implementations§

source§

impl LineTerminator

source

pub fn byte(byte: u8) -> LineTerminator

Return a new single-byte line terminator. Any byte is valid.

source

pub fn crlf() -> LineTerminator

Return a new line terminator represented by \r\n.

When this option is used, consumers may generally treat a lone \n as a line terminator in addition to \r\n.

source

pub fn is_crlf(&self) -> bool

Returns true if and only if this line terminator is CRLF.

source

pub fn as_byte(&self) -> u8

Returns this line terminator as a single byte.

If the line terminator is CRLF, then this returns \n. This is useful for routines that, for example, find line boundaries by treating \n as a line terminator even when it isn’t preceded by \r.

source

pub fn as_bytes(&self) -> &[u8]

Returns this line terminator as a sequence of bytes.

This returns a singleton sequence for all line terminators except for CRLF, in which case, it returns \r\n.

The slice returned is guaranteed to have length at least 1.

source

pub fn is_suffix(&self, slice: &[u8]) -> bool

Returns true if and only if the given slice ends with this line terminator.

If this line terminator is CRLF, then this only checks whether the last byte is \n.

Trait Implementations§

source§

impl Clone for LineTerminator

source§

fn clone(&self) -> LineTerminator

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for LineTerminator

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for LineTerminator

source§

fn default() -> LineTerminator

Returns the “default value” for a type. Read more
source§

impl Hash for LineTerminator

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<LineTerminator> for LineTerminator

source§

fn eq(&self, other: &LineTerminator) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for LineTerminator

source§

impl Eq for LineTerminator

source§

impl StructuralEq for LineTerminator

source§

impl StructuralPartialEq for LineTerminator

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.