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

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:

主站蜘蛛池模板: 克什克腾旗| 唐海县| 申扎县| 梧州市| 张家界市| 海城市| 巍山| 大姚县| 临沂市| 石门县| 康平县| 景宁| 会宁县| 定西市| 赤壁市| 含山县| 柏乡县| 枣庄市| 贵州省| 晋中市| 崇礼县| 田阳县| 黑水县| 阿鲁科尔沁旗| 乡宁县| 石渠县| 若尔盖县| 千阳县| 黔南| 商河县| 黑水县| 清新县| 彭州市| 两当县| 乌鲁木齐市| 永泰县| 喜德县| 通化县| 台州市| 扬州市| 唐山市|