3 ms·
You can't make a type that must be used exactly once, but you can often express that requirement in some other way. One technique is to require that some top-le
by twic 9y ago
You can't make a type that must be used exactly once, but you can often express that requirement in some other way. One technique is to require that some top-level function returns a value of the terminal type; then you can't accidentally abandon a computation part-way through. Here's a silly example:
https://play.rust-lang.org/?gist=b875377faa6e22b74ba8661ee106d13d&version=stable https://play.rust-lang.org/?gist=b875377faa6e22b74ba8661ee10...
That little DSL lets you make multi-layer burgers, but only where bacon and patties alternate, and there is a bun on the top.