- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 119字
- 2021-07-02 23:07:20
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.
推薦閱讀
- 自己動手寫搜索引擎
- C語言程序設(shè)計習(xí)題解析與上機指導(dǎo)(第4版)
- Learning Spring 5.0
- 劍指Offer(專項突破版):數(shù)據(jù)結(jié)構(gòu)與算法名企面試題精講
- 微服務(wù)設(shè)計原理與架構(gòu)
- 零基礎(chǔ)學(xué)Python網(wǎng)絡(luò)爬蟲案例實戰(zhàn)全流程詳解(高級進階篇)
- Yocto for Raspberry Pi
- bbPress Complete
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- Android應(yīng)用案例開發(fā)大全(第二版)
- Unity&VR游戲美術(shù)設(shè)計實戰(zhàn)
- C# Multithreaded and Parallel Programming
- 大學(xué)計算機基礎(chǔ)實驗指導(dǎo)
- Kotlin進階實戰(zhàn)
- JavaWeb從入門到精通(視頻實戰(zhàn)版)