Peterlog

  1. 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 …
  2. 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 …
  3. 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 …

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

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

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

« Page 2 / 10 »