pub(crate) struct Source<'a> {
text: Option<Cow<'a, str>>,
line_ending: LineEnding,
}Expand description
The current source of a document and the line ending to write.
Fields§
§text: Option<Cow<'a, str>>§line_ending: LineEndingImplementations§
Source§impl<'a> Source<'a>
impl<'a> Source<'a>
Sourcepub(crate) fn read(
current: Option<&'a [u8]>,
spec: LineEndingSpec,
partial: bool,
) -> Result<Self, DocumentError>
pub(crate) fn read( current: Option<&'a [u8]>, spec: LineEndingSpec, partial: bool, ) -> Result<Self, DocumentError>
Decode current and resolve the line ending of spec.
The bytes are only read when they can matter, which is under partial ownership or to preserve their line ending. The text is only kept under partial ownership, with its line endings changed to LF.
§Errors
Returns an error for invalid UTF-8 and for a current source whose line endings cannot be resolved.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Source<'a>
impl<'a> RefUnwindSafe for Source<'a>
impl<'a> Send for Source<'a>
impl<'a> Sync for Source<'a>
impl<'a> Unpin for Source<'a>
impl<'a> UnsafeUnpin for Source<'a>
impl<'a> UnwindSafe for Source<'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