-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
io::Seek should implement .tell() #1181
Comments
Oh, no. An issue here doesn't help much, and may be ignored easily. I'd
like to suggest you creating an RFC, which maybe very short for adding
`File::tell`. They required to do this trivial thing, not me. So, good
luck. I prefer to the proposal.
|
👍; the syntax is so much nicer (and I agree that Also, I'm wondering about compresseded stream, like |
pub trait Tell {
fn tell(&self) -> std::io::Result<u64>;
}
impl Tell for Seek {
fn tell(&self) -> std::io::Result<u64> {
unsafe {
let s = self as *const Self;
let s = s as *mut Self;
(*s).seek(SeekFrom::Current(0))
}
}
}
EDIT: Don't do this. |
It's unsound to create a &mut T from a &T. |
EDIT: Don't do this. |
"should not" is not the same thing as "must not". It is totally possible and fine for code to implement seek right now in a way that mutates internal state. |
Relevant link: the seek_convenience feature implements this as |
A file.tell() is much nicer than file.seek(std::io::SeekFrom::Current(0)). Additionally, I think .tell() doesn't need the file to be mutably borrowed (but I'm not sure).
The text was updated successfully, but these errors were encountered: