Rust Programming Tutorial #17 - Structs

In this video I take you through how you can create and use your own structs in Rust.
Structs allow you to group similar pieces of information together to make a new simple data type you can then use later on.
It can make your code much cleaner and easier to read.
If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!

Пікірлер: 25

  • @gabrielmendietahernandez3320
    @gabrielmendietahernandez33206 ай бұрын

    Good video, but I was flabbergasted when I saw you were using light mode😭

  • @kyleeames8229
    @kyleeames82295 жыл бұрын

    The color he used in his example is best described as hot pink.

  • @voffknur
    @voffknur6 жыл бұрын

    Thanks for making this tutorial series Love it :-) Question, is there any good UI lib/frameworks you have used with rust ? Native or similar to electron (where rust is backend instead of nodejs)

  • @dcode-software

    @dcode-software

    6 жыл бұрын

    Hi there, unfortunately I haven't had much exposure to Rust UI frameworks but I'll note this down in my list of suggestions! Thanks for your support I appreciate it 😁

  • @baxiry.
    @baxiry.6 жыл бұрын

    Thank you very much

  • @dcode-software

    @dcode-software

    6 жыл бұрын

    You're welcome!

  • @batanyaedits
    @batanyaedits Жыл бұрын

    Hey man thank you for these rust videos. And I understand your videos ("I don't speak English") but still. So if you have knowledge, can you make an arm programming video with rust? thank you again

  • @theboogymaster
    @theboogymaster5 жыл бұрын

    Very nice tutorials for rust. Could you go in a more advanced tutorials ?

  • @dcode-software

    @dcode-software

    5 жыл бұрын

    Thanks mate! Right now I'm not focusing on Rust, I may go back to it in future 😁

  • @Take_it_E-z

    @Take_it_E-z

    5 жыл бұрын

    @@dcode-software Do you know of any sites that teach more about rust? Or any friends who know how to code advanced in it?

  • @dcode-software

    @dcode-software

    5 жыл бұрын

    Unfortunately not, sorry 🙁

  • @DirtPoorWargamer
    @DirtPoorWargamer5 жыл бұрын

    Question concerning structs and mutability: is it possible to make some of the fields in a struct mutable while keeping others immutable? Not sure what the use case would be, but it was a question that crossed my mind none-the-less.

  • @victorsarkisov4480

    @victorsarkisov4480

    4 жыл бұрын

    Good question. Wondering the same thing lol

  • @davidlanday6102

    @davidlanday6102

    3 жыл бұрын

    I suppose you could make a struct of structs in which some of the structs are simply mutables? I dunno, new to rust so only speculating. Your comment is 2 years old so I suppose you have your answer

  • @NouifrUIwefdf

    @NouifrUIwefdf

    Жыл бұрын

    No, But there is a way around using "std::cell::Cell"

  • @ianh0407
    @ianh04078 ай бұрын

    Hmmm... thanks, but that leaves me with more questions than answers... e.g. what if, taking your example, you only wanted blue to be mutable? possible?

  • @lesestrickshon
    @lesestrickshon2 жыл бұрын

    I am the 20,000s viewer

  • @samdavepollard
    @samdavepollard Жыл бұрын

    probably worth mentioning that there's no rule that the fields in a struct need to all be of the same type so this should be fine: struct Person{ name: String, age: u8, owns_a_goldfish: bool, }

  • @NouifrUIwefdf
    @NouifrUIwefdf Жыл бұрын

    For defining structs you don't have to get outside of the main function, it is just about scope.

  • @gabrielmendietahernandez3320

    @gabrielmendietahernandez3320

    6 ай бұрын

    You could define struct outside or within the main function, just make sure it's within or an outer scope.

  • @NouifrUIwefdf

    @NouifrUIwefdf

    6 ай бұрын

    Is not that what I said!!@@gabrielmendietahernandez3320

  • @mynameupdatesannually
    @mynameupdatesannually3 жыл бұрын

    how do i use strings in structs

  • @larissavieiradias3034
    @larissavieiradias30348 ай бұрын

    Is it important put the word "struct" all the time before their name?

  • @gabrielmendietahernandez3320

    @gabrielmendietahernandez3320

    6 ай бұрын

    Yes, its necessary

  • @igorsilva736
    @igorsilva7364 жыл бұрын

    common #[derive()] used on struct, enum #[derive(Debug, Default, Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash)] doc.rust-lang.org/stable/rust-by-example/trait/derive.html