Controlling the output formatting

The std::fmt module provides the developer with a range of utilities for formatting and printing strings. Let's start with the format! macro. This macro returns a string.

We have seen that if we use println!(Hello {}, myString), the code will print the contents of myString after the Hello. The format! macro works pretty much the same, just that it returns the formatted string instead of outputting it. In fact, println! essentially uses format! itself under the hood.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset