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

Use NonMax to signal builder range constraints #2703

Merged
merged 1 commit into from
Jan 14, 2024

Conversation

GnomedDev
Copy link
Member

No description provided.

@github-actions github-actions bot added the builder Related to the `builder` module. label Jan 9, 2024
@mkrasnitski
Copy link
Collaborator

Are we sure we want to expose a third-party type to the user like this? What's it like to convert from primitive ints to NonMax versions?

@GnomedDev
Copy link
Member Author

We have already exposed it to users in many model types, constructing them is the same as NonZero.

@mkrasnitski
Copy link
Collaborator

At least for those it's easy to just call .into() on them. However, constructing them requires importing the type from nonmax. Also, we're not even limiting the value ranges (except for MAX), only signalling that Discord has a narrower range than all of u16 for instance. IMO in terms of using "ranged ints", this feels like a half-measure.

@GnomedDev
Copy link
Member Author

It is a half measure, and signalling that discord has a narrower range than u16 is exactly what is required to get someone to read the docs. It isn't easy to just call .into() for non zero types, that isn't an impl.

@mkrasnitski
Copy link
Collaborator

What do you mean? Every NonMax* provides an implementation of impl From<NonMax*> for *

@GnomedDev
Copy link
Member Author

Ah, you meant getting the value out of a NonMax.

@github-actions github-actions bot added the examples Related to Serenity's examples. label Jan 10, 2024
@arqunis arqunis added enhancement An improvement to Serenity. breaking change The public API is changed, resulting in miscompilations or unexpected new behaviour for users labels Jan 14, 2024
@arqunis arqunis merged commit b04e308 into serenity-rs:next Jan 14, 2024
22 checks passed
@GnomedDev GnomedDev deleted the nonmax-between branch January 14, 2024 12:58
arqunis pushed a commit to arqunis/serenity that referenced this pull request Jan 16, 2024
arqunis pushed a commit to arqunis/serenity that referenced this pull request Jan 22, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Mar 13, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Mar 19, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Mar 19, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Mar 31, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Apr 1, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request May 14, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Jun 9, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Jun 22, 2024
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Jul 29, 2024
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Jul 30, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Oct 7, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Oct 20, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Nov 11, 2024
GnomedDev added a commit to GnomedDev/serenity that referenced this pull request Nov 15, 2024
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Dec 8, 2024
arqunis pushed a commit to arqunis/serenity that referenced this pull request Jan 16, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Feb 1, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change The public API is changed, resulting in miscompilations or unexpected new behaviour for users builder Related to the `builder` module. enhancement An improvement to Serenity. examples Related to Serenity's examples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants