- 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.
推薦閱讀
- Java EE 6 企業(yè)級應(yīng)用開發(fā)教程
- Learning Selenium Testing Tools with Python
- Developing Middleware in Java EE 8
- Python Game Programming By Example
- Silverlight魔幻銀燈
- Reactive Programming With Java 9
- 學(xué)習(xí)正則表達(dá)式
- Mastering C++ Multithreading
- Odoo 10 Implementation Cookbook
- C#面向?qū)ο蟪绦蛟O(shè)計(jì)(第2版)
- Selenium WebDriver Practical Guide
- C語言程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)與習(xí)題精解
- Learning SaltStack(Second Edition)
- Hands-On GUI Application Development in Go
- Kotlin for Enterprise Applications using Java EE