Get the latest tech news

Pretty State Machine Patterns in Rust (2016)


A computer scientist working in open source towards a more hopeful future.

As we saw above the most natural way to attempt this is an enum, but we noted already that you can't control which transitions are actually permitted in this case. Indeed, the entire structure is consumed so if there are side effects of the transition on the parent (for example altering the average waiting time) we can't access stale values. If you recall the primary problem with the enum example above was that we had to deal with no ability to enforce transitions, and the only errors we got were at runtime when we did try.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Rust

Rust

Related news:

News photo

Show HN: val – An arbitrary precision calculator language

News photo

How to Optimize Rust for Slowness: Inspired by New Turing Machine Results

News photo

Two Years of Rust