Content deleted Content added
←Removed redirect to Rust (programming language)#Syntax and features Tags: Removed redirect harv or sfn error |
No edit summary |
||
Line 3:
The '''syntax of Rust''' is [[syntax|the set of rules]] defining how a [[Rust (programming language)|Rust]] program is written and compiled.
Rust's [[Syntax (programming languages)|syntax]] is similar to that of [[C (programming language)|C]] and [[C++]],<ref>{{Cite news |last=Proven |first=Liam |date=2019-11-27 |title=Rebecca Rumbul named new CEO of The Rust Foundation |url=https://www.theregister.com/2021/11/19/rust_foundation_ceo/ |access-date=2022-07-14 |website=[[The Register]] |language=en |quote="Both are curly bracket languages, with C-like syntax that makes them unintimidating for C programmers." |archive-date=2022-07-14 |archive-url=https://web.archive.org/web/20220714110957/https://www.theregister.com/2021/11/19/rust_foundation_ceo/ |url-status=live }}</ref><ref name=":4">{{Cite web |last=Vigliarolo |first=Brandon |date=2021-02-10 |title=The Rust programming language now has its own independent foundation |url=https://www.techrepublic.com/article/the-rust-programming-language-now-has-its-own-independent-foundation/ |archive-url=https://web.archive.org/web/20230320172900/https://www.techrepublic.com/article/the-rust-programming-language-now-has-its-own-independent-foundation/ |archive-date=2023-03-20 |access-date=2022-07-14 |website=[[TechRepublic]] |language=en-US}}</ref> although many of its features were influenced by [[functional programming]] languages such as [[OCaml]].{{sfn|Klabnik|Nichols|2019|p=263}}
== Basics ==
Although Rust syntax is heavily influenced by the syntaxes of C and C++, the syntax of Rust is far more distinct from C++ syntax than that of [[Java (programming language)|Java]] or [[C Sharp (programming language)|C#]].
Below is a [["Hello, World!" program]] in Rust. The {{Rust|fn}} keyword denotes a [[Function (computer programming)|function]], and the {{Rust|println!}} [[Macro (computer science)|macro]] (see {{Section link|2=Macros|nopage=y}}) prints the message to [[standard output]].{{sfn|Klabnik|Nichols|2019|pp=5–6}} [[Statement (computer science)|Statements]] in Rust are separated by [[Semicolon#Programming|semicolons]].
|