rust-lang / book

The Rust Programming Language

Home Page:https://doc.rust-lang.org/book/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ch6.1: Fix bad example

MuhammadAbdullahWarraich opened this issue · comments

URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/stable/book/ch06-01-defining-an-enum.html
Description of the problem:
" For example, we may want to say that Rectangle is one of a set of possible shapes that also includes Circle and Triangle. To do this, Rust allows us to encode these possibilities as an enum. "
Suggested fix:
" For example, we may want to say that Shape is one of a set of possible shapes that also includes Rectangle, Circle and Triangle. To do this, Rust allows us to encode these possibilities as an enum. "

try slices rust .it's posible and fast. 🙂

you encode in a struct.
struct triangle, struct cube, struct circle.

and can ad an integer element who refers this enum.

and these is vintage conventional way.
see slices in rust tambien.

I prefer this as-is. Thanks though!