← Quit0 / 0 correct
What is the typestate pattern?
struct Conn<S> { state: S }
struct Closed; struct Open;
impl Conn<Closed> { fn open(self) -> Conn<Open> { .. } }
impl Conn<Open> { fn send(&self, b: &[u8]) { .. } }What is the typestate pattern?
struct Conn<S> { state: S }
struct Closed; struct Open;
impl Conn<Closed> { fn open(self) -> Conn<Open> { .. } }
impl Conn<Open> { fn send(&self, b: &[u8]) { .. } }