Messages in this thread | | | Date | Mon, 24 Jul 2023 21:55:07 +0000 | From | Benno Lossin <> | Subject | Re: [PATCH v2 11/12] rust: init: add `{pin_}chain` functions to `{Pin}Init<T, E>` |
| |
On 7/24/23 18:07, Martin Rodriguez Reboredo wrote: > On 7/24/23 11:08, Benno Lossin wrote: >> This is a bit confusing to me, because dropping the value on returning `Err` >> is a safety requirement of `PinInit`. Could you elaborate why this is >> surprising? I can of course add it to the documentation, but I do not see >> how it could be implemented differently. Since if you do not drop the value >> here, nobody would know that it is still initialized. > > I knew about the requirement of dropping on `Err`, but what has caught my > attention is that `{pin_}chain` might not abide with it per the doc > comment as it says that `self` is initialized before calling `f`... > > /// First initializes the value using `self` then calls the function > /// `f` with the initialized value. > > But one can not know what would happen when `f` fails, specially if > such failure can be ignored or it's only temporarily. > > So then, the best course IMO is to mention that in some way the value is > still being initialized, kinda setting it up, and that it will be dropped > when an error is returned. WDYT?
I see, then I will just expand the documentation.
-- Cheers, Benno
| |