BaseCodeByte
Back to Rust outline
RsRustBeginnerEditable example10 min

Structs And Enums

Structs And Enums in practical Rust programs, with editable notebook code and a focused exercise.

Lesson notes

This lesson turns structs and enums into a small example you can edit, copy and run locally.

ownershiptypessystems thinking

Editable notebook cell

Starter code

1
2
3
4
5
6
7
8

Output

Editable example
Expected output:
Hello Ada

Live execution for this language is coming soon. You can edit, copy and run this code locally.

Try this

Change the sample data, predict the output and note what concept changed.

Hint: Make the smallest possible edit first.