Re: [PATCH 2/4] rust: scatterlist: Add type-state abstraction for sg_table

From: Danilo Krummrich
Date: Mon Aug 18 2025 - 08:48:58 EST


On Mon Aug 18, 2025 at 2:27 PM CEST, Alice Ryhl wrote:
> On Mon, Aug 18, 2025 at 01:16:55PM +0200, Danilo Krummrich wrote:
>> On Mon Aug 18, 2025 at 11:52 AM CEST, Alice Ryhl wrote:
>> > On Fri, Aug 15, 2025 at 07:10:03PM +0200, Danilo Krummrich wrote:
>> >> +{
>> >> + fn new(
>> >> + dev: &Device<Bound>,
>> >> + mut pages: P,
>> >> + dir: dma::DataDirection,
>> >> + flags: alloc::Flags,
>> >> + ) -> Result<impl PinInit<Self, Error> + use<'_, P>> {
>> >
>> > We would probably want to move the logic into the initializer so that we
>> > don't have the double Result here.
>>
>> That'd be nice, but I think it's not possible.
>>
>> We can't borrow from pages in the initializer closure while at the same time
>> store pages with another initializer, can we?
>>
>> Either way, it's not that big a deal I think, since this constructor is not
>> exposed to the outside world. Which is also why it didn't bother me too much.
>
> Ok. Shrug.

I mean, don't get me wrong, if you see a way to avoid the double Result, I'm
happy to change it.

(What I meant is, given the above, I thought it's not possible. But at the same
time I did not spend too much brain cycles, since the constructor is private
anyways.)