Re: [PATCH v3 0/5] rust: time: Convert hrtimer to use Instant and Delta
From: Andreas Hindborg
Date: Wed Jun 25 2025 - 04:28:45 EST
"Miguel Ojeda" <miguel.ojeda.sandonis@xxxxxxxxx> writes:
> On Tue, 24 Jun 2025 at 15:11, Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>>
>> None of the options are the right choice.
>
> That is fine (it is also what I have been arguing in the other thread
> and in previous times), but that does not imply `into_*` is not a bad
> choice if we really want to follow upstream.
>
>> Cost and ownership _do_ line
>> up for `into_*` in this case.
>
> No, ownership definitely doesn't line up: `Delta` is not `Copy` and
> there is no conceptual ownership transfer. While it says "owned ->
> owned", not being `Copy` is quite important here: the guidelines
> clarify in an example for a `Copy` type that if the input is not
> consumed then it should not be `into_*`.
OK, that makes sense. And you are right, `T: Copy` does not line up, I
must have read too fast.
>
> Sure, "Variable" cost means anything could go there, but that doesn't
> tell us much, i.e. if it was completely free, we could just as well
> pick `as_`, which would actually provide some information since you
> know it needs to be cheap.
>
> So the whole argument for `into_*` is... "it says 'Variable' cost so
> it lines up"?
You are right, there is no argument outside of "variable cost", thanks
for clarifying.
> Now, what I argued is that we may just as well define our own rules,
> since that table is confusing and doesn't cover all cases. If we do
> that, then you could propose things like "all owned->owned methods are
> `into_*`", which I think is what you are essentially implying here.
I would actually prefer that the rust-lang guidelines were clarified so
that we could just defer to those.
>
>> I do not think that is settled.
>
> If you think so, then the patch shouldn't be applied.
I understand.
Best regards,
Andreas Hindborg