Articles by Peter Sabaini

  1. When Ferrous Metals Corrode, pt. XIV

    Intro

    I'm working through chapter 15, "Iterators" in the Programming Rust book for this post.

    Iterators produce sequences of values, and all kinds of things can be iterated over – strings, collection types, files, connections, database records, etc.

    Rust iterators have a rich set of methods like fold(), map(), filter(), reduce …

  2. When Ferrous Metals Corrode, pt. XIII

    Intro

    For this post I'm looking at Chapter 14. Closures in the Rust Programming Book. A whole chapter dedicated to closures, count me in!

    Capturing Variables

    Rust closures can capture vars from the enclosing scope, as in other languages.

    Closures That Borrow

    By default closures borrow refs to captured vars …

  3. When Ferrous Metals Corrode, pt. XII

    Intro

    For this post I'm looking at Chapter 13. Utility Traits in the Programming Rust book.

    I don't expect radically new stuff here – but, given the importance of traits, rather some practical things into how idiomatic Rust should look like.

    The book defines three broad categories of utility traits:

    Language …
  4. 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 …
  5. 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 …

  6. 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 …

« Page 2 / 3 »