Skip to content

Add maybe_clamp to maybe_math #247

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

Closed
Weibye opened this issue Nov 19, 2022 · 2 comments
Closed

Add maybe_clamp to maybe_math #247

Weibye opened this issue Nov 19, 2022 · 2 comments
Labels
code quality Make the code cleaner or prettier.

Comments

@Weibye
Copy link
Collaborator

Weibye commented Nov 19, 2022

Several places in our code we are doing the following pattern:

.maybe_max(node_min_size.width)
.maybe_min(node_max_size.width),

This can instead be replaced with a maybe_clamp to better capture what is happening and why.

Maybe we should introduce a maybe_clamp, this pattern seems to be common.
It could probably be a default implementation for the trait.

Originally posted by @TimJentzsch in #246 (comment)

@Weibye Weibye added the code quality Make the code cleaner or prettier. label Nov 19, 2022
@alice-i-cecile alice-i-cecile added the good first issue Good for newcomers label Nov 19, 2022
nicoburns added a commit to nicoburns/taffy that referenced this issue Nov 19, 2022
@nicoburns
Copy link
Collaborator

I've implemented this on the branch for #246. Normally, I'd do a separate PR, but #246 implements MaybeMath for AvailableSpace, and I don't want to lose those impls.

@alice-i-cecile
Copy link
Collaborator

Yep I'm on board with that strategy.

@alice-i-cecile alice-i-cecile removed the good first issue Good for newcomers label Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Make the code cleaner or prettier.
Projects
None yet
Development

No branches or pull requests

3 participants