1- //! Utilities to help with buffering .
1+ //! Utilities for functions that return data via buffers .
22
33#![ allow( unsafe_code) ]
44
@@ -22,7 +22,7 @@ use core::slice;
2222///
2323/// Passing a `&mut [u8]`:
2424///
25- /// ```rust
25+ /// ```
2626/// # use rustix::io::read;
2727/// # fn example(fd: rustix::fd::BorrowedFd) -> rustix::io::Result<()> {
2828/// let mut buf = [0_u8; 64];
@@ -34,7 +34,7 @@ use core::slice;
3434///
3535/// Passing a `&mut [MaybeUninit<u8>]`:
3636///
37- /// ```rust
37+ /// ```
3838/// # use rustix::io::read;
3939/// # use std::mem::MaybeUninit;
4040/// # fn example(fd: rustix::fd::BorrowedFd) -> rustix::io::Result<()> {
@@ -48,7 +48,7 @@ use core::slice;
4848///
4949/// Passing a [`SpareCapacity`], via the [`spare_capacity`] helper function:
5050///
51- /// ```rust
51+ /// ```
5252/// # use rustix::io::read;
5353/// # use rustix::buffer::spare_capacity;
5454/// # fn example(fd: rustix::fd::BorrowedFd) -> rustix::io::Result<()> {
@@ -293,7 +293,8 @@ mod private {
293293
294294 /// Return a pointer and length for this buffer.
295295 ///
296- /// The length is the number of elements of type `T`, not a number of bytes.
296+ /// The length is the number of elements of type `T`, not a number of
297+ /// bytes.
297298 ///
298299 /// It's tempting to have this return `&mut [MaybeUninit<T>]` instead,
299300 /// however that would require this function to be `unsafe`, because
@@ -370,7 +371,10 @@ mod tests {
370371 let mut buf = [ 0_u8 ; 64 ] ;
371372 let nread = read ( & input, & mut buf) . unwrap ( ) ;
372373 assert_eq ! ( nread, buf. len( ) ) ;
373- assert_eq ! ( & buf[ ..38 ] , b"//! Utilities to help with buffering.\n " ) ;
374+ assert_eq ! (
375+ & buf[ ..58 ] ,
376+ b"//! Utilities for functions that return data via buffers.\n "
377+ ) ;
374378 input. seek ( SeekFrom :: End ( -1 ) ) . unwrap ( ) ;
375379 let nread = read ( & input, & mut buf) . unwrap ( ) ;
376380 assert_eq ! ( nread, 1 ) ;
@@ -393,11 +397,14 @@ mod tests {
393397 let mut buf = [ MaybeUninit :: < u8 > :: uninit ( ) ; 64 ] ;
394398 let ( init, uninit) = read ( & input, & mut buf) . unwrap ( ) ;
395399 assert_eq ! ( uninit. len( ) , 0 ) ;
396- assert_eq ! ( & init[ ..38 ] , b"//! Utilities to help with buffering.\n " ) ;
400+ assert_eq ! (
401+ & init[ ..58 ] ,
402+ b"//! Utilities for functions that return data via buffers.\n "
403+ ) ;
397404 assert_eq ! ( init. len( ) , buf. len( ) ) ;
398405 assert_eq ! (
399- unsafe { core:: mem:: transmute:: <& mut [ MaybeUninit <u8 >] , & mut [ u8 ] >( & mut buf[ ..38 ] ) } ,
400- b"//! Utilities to help with buffering .\n "
406+ unsafe { core:: mem:: transmute:: <& mut [ MaybeUninit <u8 >] , & mut [ u8 ] >( & mut buf[ ..58 ] ) } ,
407+ b"//! Utilities for functions that return data via buffers .\n "
401408 ) ;
402409 input. seek ( SeekFrom :: End ( -1 ) ) . unwrap ( ) ;
403410 let ( init, uninit) = read ( & input, & mut buf) . unwrap ( ) ;
@@ -423,7 +430,10 @@ mod tests {
423430 let nread = read ( & input, spare_capacity ( & mut buf) ) . unwrap ( ) ;
424431 assert_eq ! ( nread, buf. capacity( ) ) ;
425432 assert_eq ! ( nread, buf. len( ) ) ;
426- assert_eq ! ( & buf[ ..38 ] , b"//! Utilities to help with buffering.\n " ) ;
433+ assert_eq ! (
434+ & buf[ ..58 ] ,
435+ b"//! Utilities for functions that return data via buffers.\n "
436+ ) ;
427437 buf. clear ( ) ;
428438 input. seek ( SeekFrom :: End ( -1 ) ) . unwrap ( ) ;
429439 let nread = read ( & input, spare_capacity ( & mut buf) ) . unwrap ( ) ;
0 commit comments