The From
trait is currently defined as:
pub trait From<T>: Sized {
fn from(_: T) -> Self;
}
The name of the argument is _
. I am proposing to change it to value
, ie.
pub trait From<T>: Sized {
fn from(value: T) -> Self;
}
This would be more consistent with the TryFrom
, which looks like this:
pub trait TryFrom<T>: Sized {
type Error;
fn try_from(value: T) -> Result<Self, Self::Error>;
}
The reason for this proposal is twofold:
- Consistency with the rest of the standard library. The
TryFrom
trait usesvalue
, and noFrom
implementation uses the default name (as it is quite useless). - When generating trait implementations with rust-analyzer/IntelliJ, the parameter name is copied, and it always has to be changed.
Optionally, another name like x
could be used. I only propose value
for consistency with TryFrom
.
Changing parameter names is not a breaking change.