lkml.org 
[lkml]   [2024]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 1/4] rust: uaccess: add userspace pointers
On Tue, Feb 27, 2024 at 11:05 AM Carlos López <clopez@suse.de> wrote:
>
>
> On 8/2/24 16:47, Alice Ryhl wrote:
> > + /// Create a reader that can access the same range of data.
> > + ///
> > + /// Reading from the clone does not advance the current reader.
> > + ///
> > + /// The caller should take care to not introduce TOCTOU issues, as described
> > + /// in the documentation for [`UserSlice`].
> > + pub fn clone_reader(&self) -> UserSliceReader {
> > + UserSliceReader {
> > + ptr: self.ptr,
> > + length: self.length,
> > + }
> > + }
>
> Just out of curiosity, is there any reason why this is not implemented
> in terms of the Clone trait?

I think people find a non-Clone-trait method higher friction than just
calling .clone(), so this nudges people towards not using it if they
don't really need it.

But really, it could go either way. It would be okay to use the Clone trait.

Alice

\
 
 \ /
  Last update: 2024-05-27 15:24    [W:0.099 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site