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

The difference between println! and println

Up to this point, we've used println! for outputting text. This is fine, but consider what println! does. Whenever you see a ! mark, it symbolizes a macro. Macros are used when some part of the function needs to be executed at compile time, rather than at runtime.

Consider the following:

println!("{}", a); 
Console.WriteLine("{0}", a); 

In C#, the preceding snippet will output a line with the value of a on the line. In this case, a can be of any type that supports conversion to a formatted output. The same applies to Rust. A line is output with the value of a.

The println! macro is actually implemented in the Rust standard library.

主站蜘蛛池模板: 葵青区| 巴彦县| 松阳县| 保康县| 柘城县| 台东市| 新昌县| 上饶县| 牟定县| 镇沅| 岱山县| 宣武区| 津市市| 承德县| 两当县| 彭阳县| 垫江县| 湖南省| 荥阳市| 肇东市| 昭苏县| 扬州市| 青铜峡市| 壤塘县| 长泰县| 页游| 汉源县| 昌平区| 广德县| 浠水县| 江川县| 西藏| 夏河县| 丘北县| 拉孜县| 苍溪县| 额济纳旗| 宜昌市| 开平市| 南康市| 柳林县|