Rust 101 – 11: Exercises for module A2

Going through some exercises on Rust ownership, references, slices and error handling.

Series: 1: Intro, 2: Language basics, 3: Memory and ownership, 4: Exercises A1, 5: References, 6: Structs and Enums, 7: Panic and Result, 8: Methods, 9: Vec and Box, 10: Strings, 11: Exercises A2, 12: Traits, 13: Type params, 14: std Traits, 15: Lifetimes, 16: Exercises A3pt1

Links:

Rust 101 is a series of videos explaining how to write programs in Rust. The course materials for this series are developed by tweede golf. You can find more information at github.com/tweedegolf/101-rs and you can sponsor the work at github.com/sponsors/tweedegolf. They are released under the Creative Commons Attribution Share Alike 4.0 International license.

This series of videos is copyright 2024 Andy Balaam and the tweede golf contributors and is released under the Creative Commons Attribution Share Alike 4.0 International license.

Rust 101 – 10: Strings

What a String is in Rust, and how they differ from &str. Strings are resizeable arrays of bytes that are guaranteed to be in UTF-8 format. &strs are references to chunks of bytes that are also guaranteed to be in UTF-8 format.

If you want to learn more about UTF-8 and character encodings, check out my video Interesting Characters.

Series: 1: Intro, 2: Language basics, 3: Memory and ownership, 4: Exercises A1, 5: References, 6: Structs and Enums, 7: Panic and Result, 8: Methods, 9: Vec and Box, 10: Strings, 11: Exercises A2, 12: Traits, 13: Type params, 14: std Traits, 15: Lifetimes, 16: Exercises A3pt1

Links:

The course materials for this series are developed by tweede golf. You can find more information at github.com/tweedegolf/101-rs and you can sponsor the work at github.com/sponsors/tweedegolf. They are released under the Creative Commons Attribution Share Alike 4.0 International license.

This series of videos is copyright 2024 Andy Balaam and the tweede golf contributors and is released under the Creative Commons Attribution Share Alike 4.0 International license.

Rust 101 – 9: Vecs, Boxes and slices

Explanation of some of the most commonly used types in Rust: Vecs, which store lists of items, Boxes that allow us to own things that we keep on the heap, and slices that are a way of referring to parts of Vecs or arrays without owning them.

Series: 1: Intro, 2: Language basics, 3: Memory and ownership, 4: Exercises A1, 5: References, 6: Structs and Enums, 7: Panic and Result, 8: Methods, 9: Vec and Box, 10: Strings, 11: Exercises A2, 12: Traits, 13: Type params, 14: std Traits, 15: Lifetimes, 16: Exercises A3pt1

Links:

The course materials for this series are developed by tweede golf. You can find more information at github.com/tweedegolf/101-rs and you can sponsor the work at github.com/sponsors/tweedegolf. They are released under the Creative Commons Attribution Share Alike 4.0 International license.

This series of videos is copyright 2024 Andy Balaam and the tweede golf contributors and is released under the Creative Commons Attribution Share Alike 4.0 International license.

Rust 101 – 8: Writing methods using impl blocks

This time we discuss how to add methods to structs and enums, using impl blocks. Methods work similarly to other languages, but it might be a surprise that they can be defined inside separate blocks, and in fact they can be defined in multiple different blocks, which can be useful, and can also be a potential cause of confusion!

Series: 1: Intro, 2: Language basics, 3: Memory and ownership, 4: Exercises A1, 5: References, 6: Structs and Enums, 7: Panic and Result, 8: Methods, 9: Vec and Box, 10: Strings, 11: Exercises A2, 12: Traits, 13: Type params, 14: std Traits, 15: Lifetimes, 16: Exercises A3pt1

Links:

The course materials for this series are developed by tweede golf. You can find more information at github.com/tweedegolf/101-rs and you can sponsor the work at github.com/sponsors/tweedegolf. They are released under the Creative Commons Attribution Share Alike 4.0 International license.

This series of videos is copyright 2024 Andy Balaam and the tweede golf contributors and is released under the Creative Commons Attribution Share Alike 4.0 International license.

Rust 101 – 7: Error handling with panic and Result

We learnt about enums and generics last time, which means we’re ready to talk about Result, which is a really nice way of handling errors in Rust, that allows you to be very explicit about what went wrong, but also with a very compact syntax using the ? operator. Before that we discuss `panic!`, which essentially stops your program with an error message, and is useful for handling errors that should never happen.

Series: 1: Intro, 2: Language basics, 3: Memory and ownership, 4: Exercises A1, 5: References, 6: Structs and Enums, 7: Panic and Result, 8: Methods, 9: Vec and Box, 10: Strings, 11: Exercises A2, 12: Traits, 13: Type params, 14: std Traits, 15: Lifetimes, 16: Exercises A3pt1

Links:

The course materials for this series are developed by tweede golf. You can find more information at github.com/tweedegolf/101-rs and you can sponsor the work at github.com/sponsors/tweedegolf. They are released under the Creative Commons Attribution Share Alike 4.0 International license.

This series of videos is copyright 2023 Andy Balaam and the tweede golf contributors and is released under the Creative Commons Attribution Share Alike 4.0 International license.