11
submitted 4 months ago* (last edited 4 months ago) by maegul@lemmy.ml to c/learningrustandlemmy@lemmy.ml

Hi All!

Welcome to week 2 of Reading Club for Rust's "The Book" ("The Rust Programming Language").

Have a shot at going through "the reading" and post any thoughts, confusions or insights here

"The Reading"

Basically covering the fundamentals of the language before getting to grips with the borrow checker next chapter

The Twitch Stream

Video Tutorial

What's Next Week?

  • Chapter 4 ... Understanding Ownership
  • Start thinking about challenges or puzzles to try as we go in order to get some applied practice!
    • EG, Advent of Code ... I think @sorrybookbroke@sh.itjust.works is going to be running sessions on this on twitch? (Thursday 6.30pm EST (New York))?
    • Maybe some basic/toy web apps such as a "todo"
top 2 comments
sorted by: hot top controversial new old
[-] maegul@lemmy.ml 4 points 4 months ago* (last edited 4 months ago)

My quick take on this material ...

  • It makes it clear to the newcomer that Rust is trying to be a clean and expressive language (given its lower level nature). Those coming from languages other than C may be surprised at how familiar it feels and looks.
  • The most interesting or surprising stuff here is implicit returns and how expressions are bit more fundamentally expansive than you might expect!
    • See chapters 3.3 and 3.5 for this stuff.
    • EG, if statements and loops can be expressions (ie, they return values)
    • See the code below ... where loop is an expression returning a value, assigned to result, through the break keyword (basically, in this case, like return but for loops ... kinda cool!)
fn main() {
    let mut counter = 0;

    let result = loop {
        counter += 1;

        if counter == 10 {
            break counter * 2;
        }
    };
    println!("The result is {result}");
}
[-] maegul@lemmy.ml 2 points 4 months ago

Similarly for conditionls:

let condition = 10;

let number = {
    if condition > 5 {
        condition * 10
    } else if condition > 2 {
        condition
    } else {
        condition / 10
    }
};
this post was submitted on 14 Feb 2024
11 points (92.3% liked)

Learning Rust and Lemmy

231 readers
2 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