Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rust doesn't have varargs, so formatting functions tend to be macros (allowing to pass in multiple arguments, compile time parsing the format string to allow type checking etc) so they are generally not that trivial.

There are some examples of printing output using formatting strings in the RustCrypto readme:

    let hash = Blake2b::digest(b"my message");
    println!("Result: {:x}", hash);
https://github.com/RustCrypto/hashes#usage

If you're looking to get the actual string value rather than just print it out, then take a look at the format macro. It uses the same format strings / traits etc as println, so wherever you see println you could drop in format instead:

    let hash = Blake2b::digest(b"my message");
    let text = format!("{:x}", hash);
https://doc.rust-lang.org/std/macro.format.html


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: