Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::io;
- use std::io::prelude::*;
- use std::io::{Cursor, SeekFrom};
- trait Tell {
- fn tell(&mut self) -> io::Result<u64>;
- }
- impl<T: Seek> Tell for T {
- fn tell(&mut self) -> io::Result<u64> {
- self.seek(SeekFrom::Current(0))
- }
- }
- fn main() -> io::Result<()> {
- let mut f = Cursor::new(vec![0; 15]);
- // move the cursor 5 bytes from the start of the file
- f.seek(SeekFrom::Start(5))?;
- println!("{:?}", f.tell());
- Ok(())
- }
Add Comment
Please, Sign In to add comment