Skip to content

Commit 4002638

Browse files
Rollup merge of rust-lang#122512 - baitcode:2024-03-14-buffer-documentation-fix, r=Nilstrieb
Cursor.rs documentation fix Reason: I've been learning Rust std library and got confused. Seek trait documentation clearly states that negative indexes will cause an error. And the code in the Cursor example uses negative index. I found myself trying to understand what am I missing until I've actually executed the code and got error. I decided to submit small fix to the documentation.
2 parents 5325c2b + 07e0182 commit 4002638

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/std/src/io/cursor.rs

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, SeekFrom};
5151
/// // We might want to use a BufReader here for efficiency, but let's
5252
/// // keep this example focused.
5353
/// let mut file = File::create("foo.txt")?;
54+
/// // First, we need to allocate 10 bytes to be able to write into.
55+
/// file.set_len(10)?;
5456
///
5557
/// write_ten_bytes_at_end(&mut file)?;
5658
/// # Ok(())

0 commit comments

Comments
 (0)