Ben Chuanlong Du's Blog

It is never too late to learn.

Sum Type in Rust

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Enum is the preferred way to constrcut a sum type of several types (which does not implemente the same trait).

The Rust crate either provides an enum Either (with variants Left and Right) which is a general purpose sum type with two cases.

Comments