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

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:

主站蜘蛛池模板: 义乌市| 平武县| 临邑县| 多伦县| 舞阳县| 黔江区| 庆阳市| 大城县| 顺昌县| 旌德县| 蒙城县| 普宁市| 鄂托克旗| 平阳县| 遂川县| 舒城县| 正定县| 二连浩特市| 浦北县| 德江县| 乐山市| 会昌县| 北票市| 台东市| 泸定县| 即墨市| 屏东市| 肥城市| 巴彦县| 仁布县| 古田县| 那曲县| 蓬莱市| 涿鹿县| 新邵县| 乌鲁木齐市| 延长县| 舒城县| 旺苍县| 华阴市| 河北区|