Rust by Example - Collective of authors

Бесплатно читаем книгу Rust by Example - Collective of authors без сокращений! Чтобы читать полную версию, не нужна регистрация на сайте. Помните, что чтение доступно как на компьютере, так и на Андроиде, Айфоне и любом другом телефоне.
Rust by Example - Collective of authors

Collective of authors - Rust by Example о чем книга


https://doc.rust-lang.org/stable/rust-by-example/

Читать онлайн бесплатно Rust by Example, автор Collective of authors


Rust is a modern systems programming language focusing on safety, speed, and concurrency. It accomplishes these goals by being memory safe without using garbage collection.

Rust by Example (RBE) is a collection of runnable examples that illustrate various Rust concepts and standard libraries. To get even more out of these examples, don't forget to install Rust locally and check out the official docs. Additionally for the curious, you can also check out the source code for this site.

Now let's begin!

This is the source code of the traditional Hello World program.

>// This is a comment, and is ignored by the compiler

>// You can test this code by clicking the "Run" button over there ->

>// or if you prefer to use your keyboard, you can use the "Ctrl + Enter" shortcut

>// This code is editable, feel free to hack it!

>// You can always return to the original code by clicking the "Reset" button ->

>// This is the main function

>fn main() {

>// Statements here are executed when the compiled binary is called

>// Print text to the console

>println!("Hello World!");

>}

>הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה

>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

println! is a macro that prints text to the console.

A binary can be generated using the Rust compiler: rustc.

>$ rustc hello.rs

rustc will produce a hello binary that can be executed.

>$ ./hello

>Hello World!

Click 'Run' above to see the expected output. Next, add a new line with a second println! macro so that the output shows:

>Hello World!

>I'm a Rustacean!

Any program requires comments, and Rust supports a few different varieties:

   • Regular comments which are ignored by the compiler:

      • // Line comments which go to the end of the line.

      • /* Block comments which go to the closing delimiter. */

   • Doc comments which are parsed into HTML library documentation:

      • /// Generate library docs for the following item.

      • //! Generate library docs for the enclosing item.

>fn main() {

>// This is an example of a line comment

Вы автор?
Жалоба
Все материалы размещаются на сайте его пользователями.
Если Ваша книга была опубликована без Вашего ведома и/или без Вашего согласия, пожалуйста, напишите нам, и мы в срочном порядке примем меры.