Skip to content
New issue

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

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

Already on GitHub? # to your account

It doesn't make sense to have enumerated types implement num::One, num::Zero, or std::ops::Add. #1

Closed
RobertDurfee opened this issue Aug 12, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@RobertDurfee
Copy link
Owner

The convenience constructors (e.g. closed or all) were originally designed for numeric types. The same traits used for numeric types do not work well with enumerated types. A better set of traits would include std::iter::Step (available only with nightly) and std::default::Default. The num::Bounded trait could still be used, but it might be a little confusing because enumerated types are not numeric.

Workarounds:

  • The Segment struct does not require the use of convenience constructors to operate correctly (they are there for convenience). If your type cannot implement num::One, num::Zero, or std::ops::Add, then just use the new constructor which makes a closed-open interval.
@RobertDurfee RobertDurfee added the enhancement New feature or request label Aug 12, 2020
@RobertDurfee RobertDurfee self-assigned this Aug 12, 2020
@RobertDurfee
Copy link
Owner Author

Created new traits Bounded and Next which make more sense for enumerated types. std::default::Default is now used instead of num::Zero to remove implicit requirement for numeric types.

Fixed with 11c81d7.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant