There are currently no standardized naming conventions for constructor methods. For example, consider these methods:
QDate::from_string_enum(string: &QString, format: DateFormat) -> Option<Self>
QDateTime::from_string(string: &QString, format: DateFormat) -> Option<Self>
QTime::from_string_enum(string: &QString, format: DateFormat) -> Self
QDate::from_string_enum and QDateTime::from_string have the same signature, but different names.
QDate::from_string_enum and QTime::from_string_enum have the same name, but different signatures.
Proposal 1: Constructor methods should be the names of each parameter type, prefixed by from_. If they return Option<Self> rather than Self, the name should be suffixed by _opt, which is a common pattern in other crates. So the above would be replaced by:
QDate::from_qstring_dateformat_opt(string: &QString, format: DateFormat) -> Option<Self>
QDateTime::from_qstring_dateformat_opt(string: &QString, format: DateFormat) -> Option<Self>
QTime::from_qstring_dateformat(string: &QString, format: DateFormat) -> Self
Proposal 2: Deprecate all the constructor methods and just use From and TryFrom with tuples. So the above would be replaced by:
impl TryFrom<(&QString, DateFormat)> for QDate
impl TryFrom<(&QString, DateFormat)> for QDateTime
impl From<(&QString, DateFormat)> for QTime
Proposal 3: Do proposal 1 and the implementations from proposal 2.
There are currently no standardized naming conventions for constructor methods. For example, consider these methods:
QDate::from_string_enumandQDateTime::from_stringhave the same signature, but different names.QDate::from_string_enumandQTime::from_string_enumhave the same name, but different signatures.Proposal 1: Constructor methods should be the names of each parameter type, prefixed by
from_. If they returnOption<Self>rather thanSelf, the name should be suffixed by_opt, which is a common pattern in other crates. So the above would be replaced by:Proposal 2: Deprecate all the constructor methods and just use
FromandTryFromwith tuples. So the above would be replaced by:Proposal 3: Do proposal 1 and the implementations from proposal 2.