#macro #saturating #arithmetic #looks #macro-rules #expr #add-assign

saturating_add_assign

Convenience macro for AddAssign with saturating arithmetic

1 stable release

1.0.0 Nov 21, 2024

#684 in Rust patterns

Download history 180/week @ 2024-11-18 7/week @ 2024-11-25 14/week @ 2024-12-02

201 downloads per month

MIT license

3KB

saturating_add_assign

This crate contains the saturating_add_assign macro, which looks like this:

macro_rules! saturating_add_assign {
    ($i:expr, $v:expr) => {{
        $i = $i.saturating_add($v)
    }};
}

There is nothing else in here and there never will be. This crate exists because the Agave repo uses this macro everywhere and I wanted to rip it out without heavy dependencies. You should probably only use this crate if you were already using the original saturating_add_assign macro.

You should pin the version to 1.0.0 in your Cargo.toml file, because there isn't a clear reason why the four lines of code should ever change, and if there is a new release it could mean I got hacked.

[dependencies]
saturating_add_assign = "=1.0.0"

No runtime deps