lkml.org 
[lkml]   [2023]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v2 2/7] rust: cred: add Rust abstraction for `struct cred`
On Mon, Dec 11, 2023 at 03:34:29PM +0000, Alice Ryhl wrote:
> Boqun Feng <boqun.feng@gmail.com> writes:
> > On Wed, Dec 06, 2023 at 11:59:47AM +0000, Alice Ryhl wrote:
> > [...]
> > > @@ -151,6 +152,21 @@ pub fn as_ptr(&self) -> *mut bindings::file {
> > > self.0.get()
> > > }
> > >
> > > + /// Returns the credentials of the task that originally opened the file.
> > > + pub fn cred(&self) -> &Credential {
> >
> > I wonder whether it would be helpful if we use explicit lifetime here:
> >
> > pub fn cred<'file>(&'file self) -> &'file Credential
> >
> > It might be easier for people to get. For example, the lifetime of the
> > returned Credential reference is constrainted by 'file, the lifetime of
> > the file reference.
> >
> > But yes, maybe need to hear others' feedback first.
> >
> > Regards,
> > Boqun
>
> That would trigger a compiler warning because the lifetime is
> unnecessary.
>

We can disable that warning if people need the information. Code is
mostly for reading, less often for compilation and changes.

> The safety comment explains what the signature means. I think that
> should be enough.
>

For someone who has a good understanding of Rust lifetime (and the
elision), yes. But I'm wondering whether all the people feel the same
way.

Regards,
Boqun

> Alice
\
 
 \ /
  Last update: 2023-12-11 18:36    [W:0.062 / U:2.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site