Re: [PATCH v1 1/5] rust: time: Change Delta methods to take &self instead of self

From: FUJITA Tomonori
Date: Tue Jun 03 2025 - 09:31:27 EST


On Mon, 02 Jun 2025 14:19:38 +0200
Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:

> "Alice Ryhl" <aliceryhl@xxxxxxxxxx> writes:
>
>> On Sun, May 04, 2025 at 01:59:54PM +0900, FUJITA Tomonori wrote:
>>> Change several methods of the `Delta` type in Rust to take `&self`
>>> instead of `self`. These methods do not mutate or consume the `Delta`
>>> value and are more idiomatically expressed as taking a shared
>>> reference. This change improves consistency with common Rust practice
>>> and allows calling these methods on references without requiring an
>>> explicit copy or move of the value.
>>
>> For small values that can be freely copied, I actualy think that using
>> `self` is more common Rust practice.
>
> Besides best practice, the value will pass in a register. There is no
> benefit at all from passing a reference here and no improved ergonomics
> from using a reference.

Yeah, but somehow I thought that using &self is more common practice
in Rust.

I'll drop this patch in the next version.