[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <rfx55e62g3uvdwunxtfkhheyhgnfgladthezuig2gk4uaaksat@pd4pttamfff2>
Date: Wed, 25 Oct 2023 12:22:35 +0000
From: "Ariel Miculas (amiculas)" <amiculas@...co.com>
To: Alice Ryhl <aliceryhl@...gle.com>
CC: "nmi@...aspace.dk" <nmi@...aspace.dk>,
"alex.gaynor@...il.com" <alex.gaynor@...il.com>,
"benno.lossin@...ton.me" <benno.lossin@...ton.me>,
"bjorn3_gh@...tonmail.com" <bjorn3_gh@...tonmail.com>,
"boqun.feng@...il.com" <boqun.feng@...il.com>,
"gary@...yguo.net" <gary@...yguo.net>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"ojeda@...nel.org" <ojeda@...nel.org>,
"patches@...ts.linux.dev" <patches@...ts.linux.dev>,
"rust-for-linux@...r.kernel.org" <rust-for-linux@...r.kernel.org>,
"wedsonaf@...il.com" <wedsonaf@...il.com>
Subject: Re: [PATCH v1] rust: add improved version of
`ForeignOwnable::borrow_mut`
On 23/08/23 10:34AM, Alice Ryhl wrote:
> Andreas Hindborg <nmi@...aspace.dk> writes:
> >>> I am not sure this makes sense. How about splitting the trait in two,
> >>> immutable and mutable and only implementing the immutable one or Arc?
> >>
> >> I used this design based on what would make sense for a linked list. The
> >> idea is that we can have two different types of cursors for a linked
> >> list: immutable and mutable. The immutable cursor lets you:
> >>
> >> * move around the linked list
> >> * access the values using `borrow`
> >>
> >> The mutable cursor lets you:
> >>
> >> * move around the linked list
> >> * delete or add items to the list
> >> * access the values using `borrow_mut`
> >>
> >> The mutable cursor gives you extra abilities beyond the `borrow` vs
> >> `borrow_mut` distinction, so we want to provide both types of cursors
> >> even if the pointer type is Arc. To do that, we need a trait that
> >> defines what it means to have mutable access to an Arc.
> >
> > I don't see how that prevents this trait from being split in two?
>
> Well, you could split the trait, but if you make the mutable iterator
> require the `borrow_mut` trait, then you have to implement the mutable
> trait for `Arc` too if you want the mutable iterator to work with `Arc`.
>
> And if you're always going to implement both traits, then maybe it
> makes more sense to not split the traits?
>
> Alice
I see this patch present in the rust-dev branch, but not in rust-next.
Are there plans for including this patch in rust-next?
Cheers,
Ariel
Powered by blists - more mailing lists