3 ms·
Nice post. For some reason I can never remember the syntax for formatting and I have to look it up each time. I’ll bookmark your post for the next time I need t
by nindalf 5y ago
Nice post. For some reason I can never remember the syntax for formatting and I have to look it up each time. I’ll bookmark your post for the next time I need this.
- nicoburns 5y agoIt might help you to remember that the syntax is `{identifier:flags}` where identifier being left blank signifies a positional argument to the formatting macro. Although if it's the specific flags you're having trouble remembering, I can't help you as I can't remember them either except `?` (debug print) and `#?` (pretty debug print).
- nindalf 5y agoThanks Nico!
- 1f60c 5y agoA little hack: if you know the C-style format string you want to use, use that. The build will fail, of course, but Rust will tell you what to use instead.
- estebank 5y agoEven more: those suggestions that you see when calling cargo/rustc? They are also applicable through a tooltip with rust-analyzer. rustc has json output where the substitutions are represented in a machine-friendly format. :)
- jackosdev 5y agoThanks really appreciate it, happy to be in someone's bookmarks
- bobbylarrybobby 5y agoThe full spec is here: https://doc.rust-lang.org/std/fmt/index.html https://doc.rust-lang.org/std/fmt/index.html