let blocks

It’s kinda obvious now that I’ve typed it, but the builder pattern in rust can work, even if you don’t expect it to.

let already_initialised = { do_stuff_here() };

use std::fmt;
struct Foo { a: u64 }
impl Foo {
    fn build(&self) -> String {
        format!("!{}!", self.a)
    }
}

impl From for Foo {
    fn from(item: u64) -> Self {
        Self { a: item }
    }
}

impl fmt::Display for Foo {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "={}=", self.a)
    }
}

fn main() {
    let z = {
        let a = Foo::from(1);

        // Things to try:
        // a
        // a.build().to_owned()
        a.build()
    };

    println!("{}", z);
}