5

Finally, we can make our own types (or data structures)!!


This is supplementary/separate from the Twitch Streams (see sidebar for links), intended for discussion here on lemmy.

The idea being, now that both twitch streams have read Chapters 5 and 6, we can have a discussion here and those from the twitch streams can have a retrospective or re-cap on the topic.

This will be a regular occurrence for each discrete set of topics coming out of The Book as the twitch streams cover them


With Ch 4 on the borrow checker out of the way, chapters 5 & 6 feel like the "inflection point" ... the point where we're ready to actually start programming in rust.

Custom types, data structures, objects with methods, pattern matching, and even dipping into rust's traits system and it's quasi answer to class inheritance.

If you're comfortable enough with the borrow checker, you can really start to program with rust now!


I personally didn't think this content was difficult, though it prompts some interesting points and topics (which I'll mention in my own comment below).

  • Any thoughts, difficulties or confusions?
  • Any quizzes stump you?
  • Any major tips or rules of thumb you've taken away or generally have about using structs and enums?
you are viewing a single comment's thread
view the rest of the comments
[-] Jayjader@jlai.lu 2 points 5 days ago

Bit of both, I suppose. Along with my own experience trying to deal with prototypes in JavaScript and how Python handles methods vs "bare" functions internally in terms of v-tables and "where" things exist in memory.

I imagine the fact that both of those are interpreted languages plays somewhat heavily into it.

With regards to being able to write MyStruct::my_method(&my_var), it's the one-two punch of "I can use that specific syntax to differentiate between 'inherited' methods that have the same name" and that the compiler doesn't treat .method() calls any differently and just rewrites them as such when doing it's job.

[-] maegul@lemmy.ml 1 points 5 days ago

I imagine the fact that both of those are interpreted languages plays somewhat heavily into it.

Yea I'd imagine so too.

this post was submitted on 21 Jun 2024
5 points (100.0% liked)

Learning Rust and Lemmy

231 readers
5 users here now

Welcome

A collaborative space for people to work together on learning Rust, learning about the Lemmy code base, discussing whatever confusions or difficulties we're having in these endeavours, and solving problems, including, hopefully, some contributions back to the Lemmy code base.

Rules TL;DR: Be nice, constructive, and focus on learning and working together on understanding Rust and Lemmy.


Running Projects


Policies and Purposes

  1. This is a place to learn and work together.
  2. Questions and curiosity is welcome and encouraged.
  3. This isn't a technical support community. Those with technical knowledge and experienced aren't obliged to help, though such is very welcome. This is closer to a library of study groups than stackoverflow. Though, forming a repository of useful information would be a good side effect.
  4. This isn't an issue tracker for Lemmy (or Rust) or a place for suggestions. Instead, it's where the nature of an issue, what possible solutions might exist and how they could be or were implemented can be discussed, or, where the means by which a particular suggestion could be implemented is discussed.

See also:

Rules

  1. Lemmy.ml rule 2 applies strongly: "Be respectful, even when disagreeing. Everyone should feel welcome" (see Dessalines's post). This is a constructive space.
  2. Don't demean, intimidate or do anything that isn't constructive and encouraging to anyone trying to learn or understand. People should feel free to ask questions, be curious, and fill their gaps knowledge and understanding.
  3. Posts and comments should be (more or less) within scope (on which see Policies and Purposes above).
  4. See the Lemmy Code of Conduct
  5. Where applicable, rules should be interpreted in light of the Policies and Purposes.

Relevant links and Related Communities


Thumbnail and banner generated by ChatGPT.

founded 5 months ago
MODERATORS