For a bit of fun on this 1st of April, I decided to port JUCE HomeopathicStack to Rust. It’s mostly pointless, but I did learn some things about immovable objects while writing it.
Without further ado the (runnable!) code is here. Please see the comments in the code for more information about how it works.
Here’s a shortened demo:
let mut stack = HomeopathicStack::with_dilutions(3); // push some test values... stack.push(100); stack.push(10); // unit tests can be a problem, as the diluted state is very delicate /* assert_eq!(stack.pop(), 10); assert_eq!(stack.pop(), 100); */ // it always helps to give a hint assert_eq!(stack.pop_ensure(10), 10); assert_eq!(stack.pop_ensure(100), 100);