What can we learn from HelloWorld

fn main() {
    println!("Hello, world!");

Main function

Trust also takes the main function as the entry point of the executable program. The main function is the default main function entry, which has no return value and no parameters.

Keyword FN

FN is the abbreviation of function. When writing a function definition, FN is essential.


main.rs The file suffix for is.rs. Compilation requires executionrustc main.rs


Statement must be;ending. Statement blocks use braces.


println!Is a printout macro, not a function. How to distinguish macro from function? exclamatory mark,printlnIt is followed by an exclamation point, which means it is a macro.


After windows compiles, the EXE file is generated and the command can be executed.\main.exe. Under Linux, execute the command./main

reference resources

This work adoptsCC agreementReprint must indicate the author and the link of this article

Recommended Today

New JavaScript syntax “double question mark syntax” and “optional chain syntax”

Double question mark grammar Double question mark grammarThe concept is to return the value on the right when the value on the left is null or undefined let Form = undefined ?? true; //Form = true Alternative chain syntax ? optional chain //Optional chain let body = { value: { a: ‘123321’ } } let […]