Closed MarcoIeni closed 1 year ago
Even setting aside whether this is desired, two issues immediately come to mind. The first is that any code like Duration::seconds(0)
would break due to inference. The other is that .into()
is a trait method that cannot currently be performed in const
contexts. As such, this change could not be made even if it were desired (which is questionable in my opinion).
Hi 👋 I have a suggestion to simplify creating a
Duration
.Current situation
The methods
Duration::seconds
,Duration::minutes
, etc., take ani64
as an argument.For example, the following works:
However, when you have other types, you need to explicitly convert the number to an i64 by calling
.into()
:Suggestion
Can we change those methods to automatically convert to an i64? For example,
Duration::seconds
from this:can become:
The advantage is that the caller doesn't have to write
.into()
explicitly.What do you think? I'm not sure if what I'm suggesting is more idiomatic, or if it's better that the caller explicitly calls
into()
. 🤔