pub struct Cursor<T> { /* private fields */ }Expand description
A cursor-like writer structure returned by FStr::writer_at.
See the FStr::writer_at documentation for the detailed behavior of this type’s fmt::Write
implementation.
§Examples
use core::fmt::Write as _;
let mut buffer = FStr::<20>::from_ascii_filler(b'.');
assert_eq!(buffer, "....................");
let mut cursor = buffer.writer_at(0);
assert_eq!(cursor.position(), 0);
assert_eq!(&cursor.get_ref()[..], "....................");
write!(cursor, "gentle")?;
assert_eq!(cursor.position(), 6);
assert_eq!(&cursor.get_ref()[..], "gentle..............");
write!(cursor, " flamingo")?;
assert_eq!(cursor.position(), 15);
assert_eq!(&cursor.get_ref()[..], "gentle flamingo.....");
assert_eq!(
cursor.get_ref().split_at(cursor.position()),
("gentle flamingo", ".....")
);
assert_eq!(buffer, "gentle flamingo.....");Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Cursor<T>where
T: Freeze,
impl<T> RefUnwindSafe for Cursor<T>where
T: RefUnwindSafe,
impl<T> Send for Cursor<T>where
T: Send,
impl<T> Sync for Cursor<T>where
T: Sync,
impl<T> Unpin for Cursor<T>where
T: Unpin,
impl<T> UnsafeUnpin for Cursor<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Cursor<T>where
T: UnwindSafe,
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