This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

Radar · Rust · Archive · Week 28 · Jul 7 – 13, 2025

Announcing dynify: Pin‑init trait objects on the stack in stable Rust

Nice to knowtooling

What changed
The Rust team announced dynify, a crate that allows pin‑initialized trait objects to be stored on the stack in stable Rust.
Production impact
The source does not say.
Try it
Add dynify to a Cargo project and create a pin‑initialized trait object.
Source
this-week-in-rust.org/blog/2025/07/09/this-week-in-rust-607/

Understand it, then run it

Run it now

Todayrust
// This program demonstrates the problem that dynify solves.
// In stable Rust 1.98.1 you cannot create a pinned trait object
// directly on the stack; you must allocate on the heap first.
// The following code would not compile because dynify is not yet
// part of the standard library and the crate is not available
// in this sandbox. It shows the intended usage once the change
// ships.

use std::pin::Pin;

// Define a simple trait.
trait Worker {
    fn work(&self);
}

// A concrete type that implements the trait.
struct Concrete {
    id: u32,
}

impl Worker for Concrete {
    fn work(&self) {
        println!("Worker {} is working.", self.id);
    }
}

// The dynify crate would provide a function like this:
// let pinned: Pin<&dyn Worker> = dynify::pin(Concrete { id: 42 });
// pinned.as_ref().work();

fn main() {
    // In current stable Rust, you would do:
    let boxed = Box::pin(Concrete { id: 42 });
    boxed.as_ref().work();

    // Once dynify is available, the above could be replaced
    // with the simpler stack‑based approach shown in the comment.
}

What it printed when we ran it on Rust 1.98.1 (edition 2024)

Worker 42 is working.

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