Skip to content

Minor API proposal: change From to Into #999

@Lucretiel

Description

@Lucretiel

Several Tree methods (insert being the most obvious) have an interface like this:

fn modify<V>(&self, value: V)
    where IVec: From<V> { ... }

I propose changing these to where V: Into<IVec>, for the following reasons:

  • It allows a slightly larger set of input types, as there are rare cases where Into<T> can be implemented but T: From<U> cannot.
  • It allows the trait bound to be on V, the input parameter type, which personally I find to be cleaner than an indirect bound on IVec.
  • Generally, using Into<T> is more common in Rust APIs [citation needed].
  • This is a strictly forwards-compatible change, because T: From<U> implies U: Into<T>.

I'm happy to go through and make this change myself, but I wanted to first propose the change and get feedback / approval.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions