Skip to content

Comment on Functional State Machines in Rust: Typestate and Newtype Patternsparent

Comments

I think my point is that types and “typestate” do not need to be two separate things. For example, in the Lua API for C, one obviously requires a Lua context handle in order to perform any other operations, so the handle must be obtained first, by calling the context initializer function. There is no need for an extra “typestate” parameter since the dependency is explicit and enforced.

My Ticket example is not the standard type state pattern. Usually the State is shimmied in as a generic into the type being mutated

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.