-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2e72c0
commit ff3ae45
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::fs::OpenOptions; | ||
use std::io::prelude::*; | ||
use std::io::SeekFrom; | ||
|
||
fn main() { | ||
let mut file = OpenOptions::new() | ||
.append(true) | ||
.read(true) | ||
.create(true) | ||
.open("file") | ||
.unwrap(); | ||
|
||
// file offset must be 1 now | ||
write!(file, "{}", "a").unwrap(); | ||
|
||
// rewind should not work on file in append mode | ||
// since the offset must always be at the end of the file | ||
let _ = file.rewind(); | ||
|
||
// file offset must be 2 now | ||
write!(file, "{}", "b").unwrap(); | ||
|
||
assert_eq!(file.seek(SeekFrom::Current(0)).unwrap(), 2); | ||
} |