Make a class that cannot hold a broken state
Are your rules only enforced inside __init__? Then nothing stops anyone afterward. You check on every assignment with a descriptor, and work out derived values rather than holding them.
Projects / Programming languages / Advanced
What you end up with
A measurement of the peak, and cuts in two directions. Reduce what is held at once first — an order backed by your own numbers.
Sign up for a free membership to read every free project. Already have an account? Please sign in.
Log in to send a report.
Are your rules only enforced inside __init__? Then nothing stops anyone afterward. You check on every assignment with a descriptor, and work out derived values rather than holding them.
With Box<dyn Error> all you learn is that it failed. You write the possible failures out as an enum, so that adding one makes the compiler stop every caller. Up to where thiserror ends and anyhow begins.
You look up a key you know you put in, and get null back. There are four causes, and all of them compile. You measure how entries become unreachable, sort out what a record fixes and what it doesn't, and finish by making the keys immutable.