Rust
概述
参考:
学习资料
B 站-软件工艺师,Rust 编程语言入门教程(Rust 语言/Rust 权威指南配套)
公众号 - 张晋涛,我的 Rust 之旅,以及如何学习 Rust
Hello World
代码:hello_world.rs
fn main() {
println!("Hello, world!");
}
$ rustc main.rs
$ ./main
Hello, world!
Rust 语言关键字
参考:
as- perform primitive casting, disambiguate the specific trait containing an item, or rename items inuseandextern cratestatementsasync- return aFutureinstead of blocking the current threadawait- suspend execution until the result of aFutureis readybreak- exit a loop immediatelyconst- define constant items or constant raw pointerscontinue- continue to the next loop iterationcrate- link an external crate or a macro variable representing the crate in which the macro is defineddyn- dynamic dispatch to a trait objectelse- fallback forifandif letcontrol flow constructsenum- define an enumerationextern- link an external crate, function, or variablefalse- Boolean false literalfn- define a function or the function pointer typefor- loop over items from an iterator, implement a trait, or specify a higher-ranked lifetimeif- branch based on the result of a conditional expressionimpl- implement inherent or trait functionalityin- part offorloop syntaxlet- bind a variableloop- loop unconditionallymatch- match a value to patternsmod- define a modulemove- make a closure take ownership of all its capturesmut- denote mutability in references, raw pointers, or pattern bindingspub- denote public visibility in struct fields,implblocks, or modulesref- bind by referencereturn- return from functionSelf- a type alias for the type we are defining or implementingself- method subject or current modulestatic- global variable or lifetime lasting the entire program executionstruct- define a structuresuper- parent module of the current moduletrait- define a traittrue- Boolean true literaltype- define a type alias or associated typeunion- define a union and is only a keyword when used in a union declarationunsafe- denote unsafe code, functions, traits, or implementationsuse- bring symbols into scopewhere- denote clauses that constrain a typewhile- loop conditionally based on the result of an expression
Rust 语言规范
参考:
反馈
此页是否对你有帮助?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.