Re: [PATCH v2 1/5] rust: time: Rename Delta's methods from as_* to into_*
From: Andreas Hindborg
Date: Tue Jun 10 2025 - 07:26:55 EST
"FUJITA Tomonori" <fujita.tomonori@xxxxxxxxx> writes:
> Rename Delta's methods that take self from as_* to into_* to align
> with Rust naming conventions.
>
> Using `self` is more common Rust practice for small values that can be
> freely copied [1].
>
> Clippy warns against using as_* names for trait methods that take self
> as follows:
>
> warning: methods called as_* usually take self by reference or self by mutable reference
> --> ~/linux/rust/kernel/time/hrtimer.rs:421:17
> |
> 421 | fn as_nanos(self) -> i64;
>
> Rename the `Delta` struct's methods from as_nanos(), as_micros_ceil(),
> and as_millis() to into_nanos(), into_micros_ceil(), and
> into_millis(), respectively to maintain consistency with the other
> function names.
>
> Link: https://lore.kernel.org/lkml/aD1fgizC4FPT07vt@xxxxxxxxxx/ [1]
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
Reviewed-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
Best regards,
Andreas Hindborg