Am 12.02.2025 um 17:43 hat Paolo Bonzini geschrieben: > On 2/11/25 22:43, Kevin Wolf wrote: > > + /// Reads data from the child node into a linear typed buffer. > > + pub async fn read<T: IoBuffer + ?Sized>(&self, offset: u64, buf: &mut > > T) -> io::Result<()> { > > + unsafe { > > + self.read_raw(offset, buf.buffer_len(), buf.buffer_mut_ptr()) > > + .await > > + } > > + } > > + > > + /// Reads data from the child node into a linear, potentially > > uninitialised typed buffer. > > + pub async fn read_uninit<T: SizedIoBuffer>( > > + &self, > > + offset: u64, > > + mut buf: MaybeUninit<T>, > > I think Rust doesn't guarantee no copies here, so maybe this could be
Do you think that in practice the compiler won't optimise the copy away? Or is this more of a theoretical concern? > pub async fn read_uninit<T: SizedIoBuffer>( > &self, > offset: u64, > buf: &mut MaybeUninit<T>, > ) -> io::Result<&mut T> > > using assume_init_mut(). Are you sure that callers are ok with only getting a &mut T rather than an owned T? Kevin