We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc441d6 commit d205d76Copy full SHA for d205d76
src/slice/slice_bytes.rs
@@ -37,6 +37,8 @@ impl Slice {
37
}
38
39
/// Constructs a [`Slice`] from an I/O reader by pulling in `len` bytes.
40
+ ///
41
+ /// The reader may not read the existing buffer.
42
#[doc(hidden)]
43
pub fn from_reader<R: std::io::Read>(reader: &mut R, len: usize) -> std::io::Result<Self> {
44
// Use `with_capacity` & `set_len`` to avoid zeroing the buffer
@@ -49,6 +51,11 @@ impl Slice {
49
51
builder.set_len(len);
50
52
53
54
+ /// SAFETY: Normally, read_exact over an uninitialized buffer is UB,
55
+ /// however we know that in lsm-tree etc. only I/O readers or cursors over Vecs are used
56
+ /// so it's safe
57
58
+ /// The safe API is unstable: https://github.com/rust-lang/rust/issues/78485
59
reader.read_exact(&mut builder)?;
60
61
Ok(Self(builder.freeze()))
0 commit comments