Comment

Comment by steveklabnik

The write! macro would be the equivalent here. Something like this:

    use std::io::Write;
    
    static mut S1: [u8; 17] = [0; 17];
    
    fn main() {
        unsafe {
            write!(&mut S1[..], "Hi: {}", 5).unwrap();
            
            let s = std::str::from_utf8_unchecked(&S1[..5]);
            
            println!("string: {}", s);
        }
    }

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton