Radar · Rust · Archive · Week 19 · May 5 – 11, 2025
This Week in Rust 598 – Crate of the week: structstruck
Nice to knowecosystem
- What changed
- The weekly newsletter highlighted the crate
structstruck, a proc‑macro crate for enabling nested struct/enum definitions. - Production impact
- The source does not say.
- Try it
- Add
structstruckto a Cargo project and experiment with nested definitions. - Source
- this-week-in-rust.org/blog/2025/05/07/this-week-in-rust-598/
Understand it, then run it
The newsletter highlighted the crate structstruck. It is a procedural‑macro crate that lets you write nested struct and enum definitions in a single block, instead of declaring each type separately. Rust itself has no built‑in syntax for nested type definitions, so you normally write each type on its own line. structstruck adds a macro that expands the nested syntax into the equivalent flat definitions. This change is only a convenience; it does not alter the language or the compiler.
Run it now
// This program demonstrates how nested type definitions would look
// without a crate like `structstruck`. The macro is not available
// in Rust 1.98.1, so we write the types manually.
struct Address {
street: String,
city: String,
}
struct Person {
name: String,
address: Address,
}
fn main() {
let addr = Address {
street: "123 Main St".into(),
city: "Rustville".into(),
};
let person = Person {
name: "Alice".into(),
address: addr,
};
println!("{} lives in {}", person.name, person.address.city);
}
What it printed when we ran it on Rust 1.98.1 (edition 2024)
Alice lives in Rustville
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed