pub struct SliceLineEnding<'a> { /* private fields */ }
Expand description
A byte slice line ending.
Gives up some throughput compared to the specialized single/double byte impls, but works with any length.
§Examples
use line_wrap::*;
let ending = SliceLineEnding::new(b"xyz").expect("not empty");
let mut data = vec![1, 2, 3, 4, 5, 6, 255, 255, 255, 255, 255, 255];
assert_eq!(6, line_wrap(&mut data[..], 6, 2, &ending));
assert_eq!(vec![1, 2, b'x', b'y', b'z', 3, 4, b'x', b'y', b'z', 5, 6], data);
Implementations§
Source§impl<'a> SliceLineEnding<'a>
impl<'a> SliceLineEnding<'a>
Sourcepub fn new(slice: &[u8]) -> Option<SliceLineEnding<'_>>
pub fn new(slice: &[u8]) -> Option<SliceLineEnding<'_>>
Create a line ending from the slice, returning None if the slice is empty.
Trait Implementations§
Source§impl<'a> LineEnding for SliceLineEnding<'a>
impl<'a> LineEnding for SliceLineEnding<'a>
Source§fn write_ending(&self, slice: &mut [u8])
fn write_ending(&self, slice: &mut [u8])
Write the line ending into the slice, which starts at the point where the ending should be written and is len() in length
Source§fn len(&self) -> NonZeroUsize
fn len(&self) -> NonZeroUsize
The length of this particular line ending (must be constant)
Auto Trait Implementations§
impl<'a> Freeze for SliceLineEnding<'a>
impl<'a> RefUnwindSafe for SliceLineEnding<'a>
impl<'a> Send for SliceLineEnding<'a>
impl<'a> Sync for SliceLineEnding<'a>
impl<'a> Unpin for SliceLineEnding<'a>
impl<'a> UnwindSafe for SliceLineEnding<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more