Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend to other types: NonZero*, tuples, arrays, ...? #19

Closed
dhardy opened this issue Jul 13, 2021 · 1 comment · Fixed by #21
Closed

Extend to other types: NonZero*, tuples, arrays, ...? #19

dhardy opened this issue Jul 13, 2021 · 1 comment · Fixed by #21

Comments

@dhardy
Copy link
Contributor

dhardy commented Jul 13, 2021

Currently this library is limited to basic numeric types (f*, i*, u*). Should it remain that way?

  1. std::num::NonZeroU32 etc. are essentially numeric types. So should we support those?
  2. What about numeric and vector types for third-party libraries, behind feature flags?
  3. With a few lines of code we can support tuples ((A, B) → (C, D) where A → C, B → D, also for more elements to some limit) and arrays ([A; N] → [B; N] where A → B). It's easy to add, but may impact compile times.

Concern: casting as an operation is expected to be transitive: if a → b and b → c then a → c. Supporting additional "numeric" types such as NonZero* is therefore a substantial increase in the number of conversions we must support.
(We cannot have this automatically since the type of b must be specified.)

Concern: properly casting between types from multiple third-party libraries could quickly become over-complex.

Concern: there is significant appeal in a small, minimal-dependency library.


Given the above, easy-cast will likely remain limited to standard types. Supporting arrays and small tuples may be desirable.

@dhardy
Copy link
Contributor Author

dhardy commented Feb 14, 2022

Decision: do not support NonZero* types (at least for now). It's a lot of additional casts and I don't have a use-case (although I don't have a problem with someone else making a PR covering NonZero* types similar to how From does, provided it's well tested).

Decision: do try to support third-parties implementing this crate's traits. For now, don't add any such support from here.

Decision: do implement some conversions on array/tuple types.


Pending one PR, I'll close this.

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

Successfully merging a pull request may close this issue.

1 participant