Skip to content
academia.sh

Course Advanced

The Rust Ecosystem and Advanced Topics

Published Updated

By the end of this course

Start course

01

Macros and Metaprogramming

Pattern-based code generation being a slice of the language rather than a template, generation in attribute and derive form moving into a separate compilation step, and generated syntax being used to build a readable interface.

  1. 01 Declarative Macros The course's measurement core runs from inside the program and places twelve observations into four classes — still holds, handed to the writer, outside the language, nobody checks it; the distribution is 4/3/2/3, and this lesson deepens only the two observations that fall into the 'still holds' class: the body a macro generates passes type checking, and a name inside the macro does not clash with the caller's.
  2. 02 Procedural Macros A program calls the compiler twice with std::process::Command — first a procedural macro crate, then the source that uses it — and prints only the compiled/not-compiled classification and the output match; the generated body again falls into the still holds class, but this time generation happens not in the same file but in a separate compilation step.
  3. 03 Domain-Specific Languages The same routing structure is built separately with a macro-written version and a hand-written version, shown by running it to produce the same result, and the macro version is measured for how many lines it shortens the source by; but a macro's output being readable does not bring correctness — a logically wrong path-function binding passes type checking just as easily.

02

Low-Level and Interoperability

Where the compiler hands its checking off to the writer, where a foreign function's signature is trusted without ever seeing its body, the constraints a target running in a browser brings, and what a no_std environment takes away.

  1. 01 `unsafe` Rust That an unsafe block does not close off the compiler's entire checking, only the checking that covers a few specific operations, is shown by running code: within the same block, a raw pointer read stays unchecked while a slice query is still checked.
  2. 02 The Foreign Function Interface Calling a C function whose body the compiler never sees, trusting only its declared signature; that the result of two foreign calls matches Rust's own counterpart is shown by running code, and that the correctness of the declaration is the writer's responsibility is explained.
  3. 03 The WebAssembly Target The same source needing a different body depending on the target it runs on: a body that relies on a part of the standard library (the file system) and one that does not are separated with conditional compilation, both are run on the local target, and both give the same result.
  4. 04 Embedded Targets How a target where the operating system services underlying the standard library (printing, memory allocation, panic handling) do not exist at all is made visible in the source; that two bodies doing the same job, one by allocating and one with a fixed-size buffer, give the same result is shown by running code.

03

Project Lifecycle

Setting up a modular library with conditional compilation, the guarantee given by unit and integration tests with random input generation, verifying performance claims with counts, runnable examples of documentation generated from source, and what a version promises.

  1. 01 Dependencies and Feature Flags That a piece of source excluded by conditional compilation is never seen by the compiler at all, confirmed by repeating the same observation with two separate feature flags to establish the class (nobody checks it).
  2. 02 Testing and Property-Based Testing Counting whether a property holds across two hundred inputs produced by a fixed-seed, deterministic generator, and showing within what limit this count answers a question the compiler never asks.
  3. 03 Benchmarking and Profiling Counting the number of comparisons and copies two separate sorting implementations make on the same array, and showing why this count is not enough to declare one implementation's duration shorter than the other's.
  4. 04 Documentation Measuring how two guarantee classes can stand side by side in the same source, by showing that a documentation sentence contradicts a function's real behavior without being checked by any tool, while that same function's runnable example inside the documentation is genuinely tested by invoking the documentation tool from within a program.
  5. 05 Publishing It is shown by running code that a version string sits in the source without ever being checked against the body, that version compatibility is modeled at the signature level, and that the same signature can produce different behavior — that the promise stops at the signature, not at the behavior.

Final exam

The Rust Ecosystem and Advanced Topics — Final Exam

In preparation

This course's question bank is not complete yet. The exam opens here automatically once enough questions are added.

Start typing to search.

↑↓ ↵ Esc navigate · open · close