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

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:

主站蜘蛛池模板: 德庆县| 探索| 怀来县| 德庆县| 突泉县| 文昌市| 卫辉市| 梅河口市| 古浪县| 利川市| 文水县| 错那县| 绍兴市| 新晃| 乌海市| 新蔡县| 香港| 华坪县| 达孜县| 冀州市| 个旧市| 高要市| 乐山市| 浪卡子县| 宣武区| 松江区| 政和县| 淮滨县| 林芝县| 昆明市| 祥云县| 谢通门县| 军事| 青龙| 康平县| 平舆县| 铜鼓县| 射阳县| 庆元县| 大洼县| 湘潭市|