Hello World
Classic Hello World program in Rust.
fn main() {
println!("Hello, World!");
}
Unlike other popular counterparts, println!
is a macro here instead of a function.
It prints text to the console.
Comments
Rust supports Regular comments and Doc comments.
Regular Comments
Regular comments follow the general C++ style of line(//
) and block(/* ... */
) comment forms.
// Line Comment
/*
* This is a block comment.
* It's useful for a big blob of comments.
*/
Doc Comments
Line doc comments beginning with exactly three slashes(///
), and block doc comments(/** ... */
), both outer doc comments, are interpreted as a special syntax for doc
attributes.
Line comments beginning with //!
and block comments /*! ... */
are doc comments that apply to the parent of the comment, rather than the item that follows.
/// Generate docs for the following item.
//! Generate docs for the enclosing item.
Code Challenge
Try to modify the code provided in the editor to make it print
Hello, Rust! I'm a Rustacean!
.If that did print, congratulations! You've offically written a Rust program.