Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The current auto-generated += and -= implementation is hard to read, and should be replaced with += where possible. That said, we cannot auto-replace it just yet because Rust behaves differently in debug mode, therefore we should use second best approach - a macro that clearly shows intention without all the boilerplate code. The only manual code are two macros in the src/enc/mod.rs Use this replacement file as described in other recent PRs to replace boilerplate code. <details> <summary>replacement file content</summary> ```diff @@ expression cond, expr; @@ if cond { - let _rhs = 1; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_add(_rhs as u32); +::wrapping_add!(expr, 1); } @@ expression expr; @@ -{ - let _rhs = 1; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_add(_rhs as u32); +::wrapping_add!(expr, 1); -} @@ expression expr; @@ -{ - let _rhs = 1u32; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_add(_rhs); +::wrapping_add!(expr, 1); -} @@ expression expr; @@ -{ - let _rhs = 1i32; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_add(_rhs as u32); +::wrapping_add!(expr, 1); -} @@ expression expr; @@ -{ - let _rhs = 1; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_add(_rhs as usize); +::wrapping_add!(expr, 1); -} @@ expression inc, expr; @@ -{ - let _rhs = inc; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_add(_rhs as u32); +::wrapping_add!(expr, inc as u32); -} @@ expression inc, expr; @@ -{ - let _rhs = inc; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_add(_rhs); +::wrapping_add!(expr, inc); -} @@ expression inc, expr; @@ -{ - let _rhs = inc; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_add(_rhs as u32); +::wrapping_add!(expr, inc as u32); -} @@ expression inc, expr; @@ -{ - let _rhs = inc; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_add(_rhs as usize); +::wrapping_add!(expr, inc as usize); -} @@ expression expr; @@ -{ - let _rhs = 1; - let _lhs = &mut expr; - *_lhs = (*_lhs).wrapping_sub(_rhs as usize); +::wrapping_sub!(expr, 1); -} @@ expression expr_r, expr_l; @@ -{ - let _rhs = expr_r; - let _lhs = &mut expr_l; - *_lhs *= _rhs; +expr_l *= expr_r; -} @@ expression expr_r, expr_l; @@ -{ - let _rhs = expr_r; - let _lhs = &mut expr_l; - *_lhs += _rhs; +expr_l += expr_r; -} ``` </details>
- Loading branch information