Articles by Peter Sabaini

  1. When Ferrous Metals Corrode, pt. X

    Intro

    This post corresponds to Chapter 11. Traits and Generics.

    Traits are like interfaces or abstract base classes – contracts that describe what a type can do by describing it's methods. Optionally, they can also define default implementations of the methods they prescribe.

    An example trait:

    trait Write {
        fn write(&mut …
  2. When Ferrous Metals Corrode, pt. VIII

    Intro

    This post corresponds to Chapter 9. Structs in the "Programming Rust" book.

    Rust structs are data collection; fields can be named or tuple (or there can be no fields at all). Like in Go, you can have methods bound to structs (there is no separate "class" concept).

    Named-Field Structs …

  3. When Ferrous Metals Corrode, pt. V

    Intro

    This part summarizes the sixth chapter of "Programming Rust, 2nd Edition", "Expressions".

    An Expression Language

    All control structures are expressions – they can produce a value. For example:

    let status =
      if cpu.temperature <= MAX_TEMP {
          HttpStatus::Ok
      } else {
          HttpStatus::ServerError  // server melted
      };

    Blocks and Semicolons

    A block can produce a …

  4. When Ferrous Metals Corrode, pt. IV

    Intro

    This part summarizes the fifth chapter of "Programming Rust, 2nd Edition", "References". There was talk of references before, this chapter provides some additional detail around shared and mutable references and lifetimes.

    References to Values

    We have encountered references previously. There are two types

    Shared

    r/o references, can be …

  5. When Ferrous Metals Corrode, pt. III

    Intro

    This part summarizes the fourth chapter of "Programming Rust, 2nd Edition" and deals with data ownership.

    This to me is one of the most fascinating things in Rust: how it strictly tracks which part of the code holds a piece of data, and how that ownership is passed around …

  6. When Ferrous Metals Corrode, pt. II

    Intro

    Second part of my Rust learning notes, about Rust datatypes. This corresponds with chapter 3 of Programming Rust, 2nd Edition

    Fundamental Types

    Coming from a Python-heavy background, Rust type handling is of course completely different – everything statically typed, and a lot of nuance in basic datatypes. Fortunately the compiler …

« Page 2 / 3 »