Format Strings in 1.58 - Rustnote

submited by
Style Pass
2022-01-14 00:30:03

The Rust 1.58 update today bought a very nice addition, something which was touted for edition 2021, this is a feature that's often missed by the growing number of dynamic language users that are giving Rust a try, and it's now available in stable!

If you haven't seen it before, you can set the minimum width of how items are printed to give uniform spacing with :[width]. Example to print a table with even spacing:

This quality of life improvement is significant, the first thing a programmer does when learning a new language is print output, this brings Rust on par with the most ergonomic of dynamic languages. Compiled languages can have nice things too!

Leave a Comment