Saturating add in place

Is there a way to do

x = x.saturating_add(y);

like I would in zig?

x +|= y;

I'm not aware of a built-in way on the primitives, but num_traits makes it easy enough. Or use Saturating on nightly.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.