emu-rs/snes-apu

Use wrapping integer types where necessary

Closed this issue · 3 comments

Right now wrapping checks are just ignored, as they don't happen in release builds. This is basically a hack though; we should be using proper Wrapping types etc where this is semantically what we want.

The issue is that the Wrapping types in Rust are currently missing a lot of overloads that would actually make them ergonomic, so this might be a pretty large effort to fix atm. I'll have to ask about that on the forums.

As of https://internals.rust-lang.org/t/ergonomics-of-wrapping-operations/1756/39, there's now a discussion going on about it again. I think my best move now is to branch out and convert the code to using Wrapping<T> on one branch, wrapping_xxx ops on another, and be able to show them side-by-side for comparisons and feedback. Would be cool to also add notes for pain points as I went along.

Haha, I went to build a debug build really quick to test this out, and I get a stack overflow on startup, likely because of allocating all of the internal buffers etc. This is a general problem with using Box::new instead of the box syntax, but the box syntax is still unstable. Might have to wait to address this a bit longer then.

Fixed in 6fb4dbb