Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Rename non-From implementations of from #1530

Open
orlp opened this issue Aug 7, 2023 · 1 comment
Open

Rename non-From implementations of from #1530

orlp opened this issue Aug 7, 2023 · 1 comment

Comments

@orlp
Copy link
Contributor

orlp commented Aug 7, 2023

There are some implementations of a from method that are not part of the From trait. Those should probably be renamed to something else, because they normal block usage of From.

E.g. I can't write Utf8Array::from(a) where a has type MutableUtf8Array, despite that conversion existing, because the Rust compiler interprets that as me trying to call the concrete from method for a different type. So I am either forced to write <Utf8Array as From>::from(a) or use a temporary variable with .into().

@ritchie46
Copy link
Collaborator

ritchie46 commented Aug 7, 2023

Right, I understand the sentiment.

Given that we name the iterator over Option<&str> iter and the iterator over &str iter_values, I think it would be better to rename from_slice to from_slice_values and this from that collides with From::from, from_slice.

So summarizing:

  • from(&[Option<T>]) -> from_slice(&[Option<T>])
  • from_slice(&[T]) -> from_slice_values(&[T])

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants