- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 89字
- 2021-07-02 23:07:17
Using the format! macro
The format! macro works in a way similar to string formatters in other languages:
fn main() { let home_team = "Liverpool"; let result = " beat "; let away_team = "Manchester United"; let full_line = format!("{}{}{}", home_team, result, away_team); println!("{}", full_line); }
The {} in the format strings mark spots for the following parameters. The spots are filled in order, so full_line will be a concatenation of home_team, result, and away_team.
When the preceding code snippet is compiled and executed, you will see the following:

推薦閱讀
- 深入理解Android(卷I)
- Java應(yīng)用與實(shí)戰(zhàn)
- ASP.NET Core 5.0開發(fā)入門與實(shí)戰(zhàn)
- Visual Basic編程:從基礎(chǔ)到實(shí)踐(第2版)
- Java持續(xù)交付
- Podman實(shí)戰(zhàn)
- Learning Hunk
- ExtJS高級程序設(shè)計(jì)
- Procedural Content Generation for C++ Game Development
- Java語言程序設(shè)計(jì)教程
- Python網(wǎng)絡(luò)爬蟲實(shí)例教程(視頻講解版)
- WordPress Search Engine Optimization(Second Edition)
- Functional Python Programming
- 數(shù)字媒體技術(shù)概論
- Python深度學(xué)習(xí)入門:從零構(gòu)建CNN和RNN