std-type
SeekFrom: choose an offset origin
Choose an absolute position or signed displacement relative to the end or current position. Negative final positions are invalid. Seeking beyond the end may be allowed and does not necessarily extend data until a write. Expected stdout (not executed): 3 1 Common mistake: Mixing byte offsets with character indices.
Formal Syntax & Structure
rust syntaxrust
SeekFrom::Start(u64); SeekFrom::End(i64); SeekFrom::Current(i64)Working Example
Example Snippetrust
fn main() { use std::io::{Cursor, Seek, SeekFrom}; let mut c = Cursor::new(b"abcd"); println!("{}", c.seek(SeekFrom::End(-1)).unwrap()); println!("{}", c.seek(SeekFrom::Current(-2)).unwrap());}