-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I have found these related issues/pull requests
none yet
Description
I impl From<MyType> for PgLTree
, when I later tried to convert MyType
to it by PgLTree::from(my_type)
, it resolved to the following from
method.
pub struct PgLTree {
labels: Vec<PgLTreeLabel>,
}
impl PgLTree {
/// creates ltree from a [`Vec<PgLTreeLabel>`]
pub fn from(labels: Vec<PgLTreeLabel>) -> Self {
Self { labels }
}
}
Because it's an associated function, it takes precedence over From
trait method. I have to either:
- use full qualified
<PgLTree as From<MyType>>::from(my_type)
, or - use a temp var
let ltree: PgLTree = my_type.into();
Both are annoying to write.
Prefered solution
Change it to:
impl From<Vec<PgLTreeLabel>> for PgLTree {
fn from(labels: Vec<PgLTreeLabel>) -> Self {
Self { labels }
}
}
Is this a breaking change? Why or why not?
Yes, see playground.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request