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
Good video, but I was flabbergasted when I saw you were using light mode😭
The color he used in his example is best described as hot pink.
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
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 😁
Thank you very much
@dcode-software
6 жыл бұрын
You're welcome!
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
Very nice tutorials for rust. Could you go in a more advanced tutorials ?
@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
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
5 жыл бұрын
Unfortunately not, sorry 🙁
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
4 жыл бұрын
Good question. Wondering the same thing lol
@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
Жыл бұрын
No, But there is a way around using "std::cell::Cell"
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?
I am the 20,000s viewer
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, }
For defining structs you don't have to get outside of the main function, it is just about scope.
@gabrielmendietahernandez3320
6 ай бұрын
You could define struct outside or within the main function, just make sure it's within or an outer scope.
@NouifrUIwefdf
6 ай бұрын
Is not that what I said!!@@gabrielmendietahernandez3320
how do i use strings in structs
Is it important put the word "struct" all the time before their name?
@gabrielmendietahernandez3320
6 ай бұрын
Yes, its necessary
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