Modify Cursor docs to cover Write functionality
What changed, and why it matters
This commit only changes three lines of documentation comments for a Cursor type. It updates the description to mention that the position tracking applies to both reading and writing. There is no code change, no behavior change, and no security relevance.
No action needed. This is a documentation-only change with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies doc comments in io/src/lib.rs for the rust-bitcoin project’s custom Cursor wrapper. It rephrases the struct-level documentation and the position()/set_position() method documentation to reflect that the position is tracked for both read and write operations. No implementation code was altered.
Changed components
io/src/lib.rs documentation onlyInspect captured patch +3 / −3
diff --git a/io/src/lib.rs b/io/src/lib.rs
index ae1851d8..ecabaf2f 100644
--- a/io/src/lib.rs
+++ b/io/src/lib.rs
@@ -226,7 +226,7 @@ impl BufRead for &[u8] {
fn consume(&mut self, amount: usize) { *self = &self[amount..] }
}
-/// Wraps an in memory reader providing the `position` function.
+/// Wraps an in memory buffer providing `position` functionality for read and write.
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct Cursor<T> {
inner: T,
@@ -238,7 +238,7 @@ impl<T: AsRef<[u8]>> Cursor<T> {
#[inline]
pub const fn new(inner: T) -> Self { Cursor { inner, pos: 0 } }
- /// Returns the position read up to thus far.
+ /// Returns the position read or written up to thus far.
#[inline]
pub const fn position(&self) -> u64 { self.pos }
@@ -247,7 +247,7 @@ impl<T: AsRef<[u8]>> Cursor<T> {
/// This method allows seeking within the wrapped memory by setting the position.
///
/// Note that setting a position that is larger than the buffer length will cause reads to
- /// succeed by reading zero bytes.
+ /// succeed by reading zero bytes. Further, writes will be no-op zero length writes.
#[inline]
pub fn set_position(&mut self, position: u64) { self.pos = position; }
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.