Re:Switching from C++ to Rust
by endorphine on Tuesday March 14, 2023 @06:27AM
(#35149451)
Can someone elaborate on what sum types are and an example in Rust?
[ Parent
| on HN ]
Re:Switching from C++ to Rust
by burntsushi on Tuesday March 14, 2023 @07:34AM
(#35149899)
The section on "enums and pattern matching" in the Rust book is probably a good place to start: https://doc.rust-lang.org/book/ch06-00-enums.html
A "Rust enum" is a sum type.
Re:Switching from C++ to Rust
by endorphine on Thursday March 16, 2023 @01:35PM
(#35185272)
Are there other examples of sum types besides enums, in Rust? Are the two terms synonymous?
Re:Switching from C++ to Rust
by steveklabnik on Thursday March 16, 2023 @02:28PM
(#35186181)
Rust does not have sum types outside of enums. Other languages have sum types, and may or may not call them enums depending on the language.