2B. Type State Pattern - From Python to Rust

Published: 16 April 2022
on channel: Bedroom Builds
1,685
38

Type state pattern, allows writing APIs that are validating their correct use at compile-time:

Require a function to be always called
Enforce order of function calls
Forbid a function to be called twice
Mutually exclusive function calls

useful crate: https://crates.io/crates/typed-builder

Source code for this episode (and the others of the series) can be found at https://github.com/bedroombuilds/pyth...