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”
  • maegul@lemmy.mlOPM
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    5 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.mlOPM
      link
      fedilink
      English
      arrow-up
      2
      ·
      5 months ago

      Similarly for conditionls:

      let condition = 10;
      
      let number = {
          if condition > 5 {
              condition * 10
          } else if condition > 2 {
              condition
          } else {
              condition / 10
          }
      };