官术网_书友最值得收藏!

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:

主站蜘蛛池模板: 广汉市| 吴旗县| 龙南县| 四川省| 环江| 卢氏县| 塘沽区| 山阴县| 苍南县| 大石桥市| 吐鲁番市| 合肥市| 五寨县| 茂名市| 安平县| 临澧县| 丽江市| 响水县| 南溪县| 孟州市| 蒲城县| 佛教| 霍州市| 开封县| 那曲县| 河北区| 稷山县| 体育| 天镇县| 黄大仙区| 闻喜县| 定州市| 宝应县| 彰化县| 黑水县| 郸城县| 东乡县| 聂拉木县| 华宁县| 郧西县| 吴桥县|