• Complain

it-ebooks - Learning Rust

Here you can read online it-ebooks - Learning Rust full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, publisher: iBooker it-ebooks, genre: Home and family. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

it-ebooks Learning Rust
  • Book:
    Learning Rust
  • Author:
  • Publisher:
    iBooker it-ebooks
  • Genre:
  • Year:
    2018
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Learning Rust: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Learning Rust" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

it-ebooks: author's other books


Who wrote Learning Rust? Find out the surname, the name of the author of the book and a list of all author's works by series.

Learning Rust — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Learning Rust" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Why Rust?
Why Rust?

Rust initially designed and developed by Mozilla employee Graydon Hoare as a personal project. Mozilla began sponsoring the project in 2009 and announced it in 2010. But the first stable release, Rust 1.0 released on May 15, 2015.

The goal of Rust is to be a good language for creating highly concurrent and - photo 1

The goal of Rust is to be a good language for creating highly concurrent and highly safe systems. Also as you can see on above diagram, Rust designed to provide speed and safety at the same time.

"Rust is a systems programming language focused on three goals: safety, speed, and concurrency."
__ Rust Documentation

Rust is very young and very modern language. It's a compiled programming language and it uses LLVM on its backend. Also Rust is a multi-paradigm programming language, it supports imperative procedural, concurrent actor, object-oriented and pure functional styles. It also supports generic programming and meta programming, in both static and dynamic styles.

Its design elements came from a wide range of sources.

  • Abstract Machine Model : C
  • Data types : C, SML, OCaml, Lisp, Limbo
  • Optional Bindings : Swift
  • Hygienic Macros : Scheme
  • Functional Programming : Haskell, OCaml, F#
  • Attributes : ECMA-335
  • Memory Model and Memory Management : C++, ML Kit, Cyclone
  • Type Classes : Haskell
  • Crate : Assembly in the ECMA-335 CLI model
  • Channels and Concurrency : Newsqueak, Alef, Limbo
  • Message passing and Thread failure : Erlang

and etc.

Rust doesn't use an automated garbage collection system(GC) by default.

One of Rusts most unique and compelling features is ownership, which uses to achieves memory safety. Rust creates memory pointers optimistically, checks memory pointers limited accesses at the compiler time with the usage of References and Borrowing. And it does automatic compile time memory management by checking the Lifetimes.

Rust compiler observe the code at compiler time and help to prevent many types of errors that are possible to write in C++

Installation
Installation

There are many ways to install Rust on your system. For the moment the official way to install Rust is using Rustup.

Rustup installs The Rust Programming Language from the official release channels, enabling you to easily switch between stable, beta, and nightly compilers and keep them updated. It makes cross-compiling simpler with binary builds of the standard library for common platforms.

Rustup installs rustc, cargo, rustup and other standard tools to Cargo's bin directory. On Unix it is located at $HOME/.cargo/bin and on Windows at %USERPROFILE%\.cargo\bin. This is the same directory that cargo install will install Rust programs and Cargo plugins.

More information can be found on the Github page of Rustup project.

After installing Rust you can check the current version by typing rustc --version orrustc -V on your terminal to verify the success of the installation.

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

fn means function. main function is the beginning of every Rust program.
println! prints text to the console and its ! indicate that its a macro instead of a function.

Rust files should have .rs file extension and if youre using more than one word for the file name, follow the snake_case.

compiling via rustc file.rs
executing by ./file on Linux and Mac or file.exe on Windows


These are the other usages of println! macro,

fn main () { println! ( "{}, {}!" , "Hello" , "world" ); // Hello, world! println! ( "{0}, {1}!" , "Hello" , "world" ); // Hello, world! println! ( "{greeting}, {name}!" , greeting= "Hello" , name= "world" ); // Hello, world! println! ( "{:?}" , [,,]); // [1, 2, 3] println! ( "{:#?}" , [,,]); /* [ 1, 2, 3 ] */ // format! macro is used to store the formatted STRING let x = format! ( "{}, {}!" , "Hello" , "world" ); println! ( "{}" , x); // Hello, world! }
Cargo, Crates and Basic Project Structure
Cargo, Crates and Basic Project Structure

Cargo is Rusts build-in Package Manager. But mainly it uses for,

Create new project : cargo new
Update dependencies : cargo update
Build project : cargo build
Build and run a project : cargo run
Run tests : cargo test
Generate documentation via rustdoc : cargo doc

Other than that there are some cargo commands, especially for publishing crates directly via cargo.

cargo login : acquiring an API token
cargo package : make the local create uploadable to crates.io
cargo publish : make the local create uploadable to crates.io and upload the crate

A crate is a package. Crates can be shared viaCargo.


A crate can produce an executable or a library. In other words, it can be a binary crate or a library crate.

  1. cargo new crate_name --bin : produces an executable
  2. cargo new crate_name --lib OR cargo new crate_name: produces a library

The first one generates,

Cargo.toml src main.rs

and the second one generates,

Cargo.toml src lib.rs
  • Cargo.toml(capital c) is the configuration file which contains all of the metadata that Cargo needs to compile your project.
  • src folder is the place to store the source code.
  • Each crate has an implicit crate root/ entry point. main.rs is the crate root for a binary crate and lib.rs is the crate root for a library crate.

When we build a binary crate via cargo build or cargo run, the executable file will be stored in target/debug/ folder. But when build it via cargo build --release for a release it will be stored in target/release/ folder.


This is how Cargo Docs describes about the recommended Project Layout,

. Cargo.lock Cargo.toml benches large-input.rs examples simple.rs src bin another_executable.rs lib.rs main.rs tests some-integration-tests.rs

Source code goes in the src directory.
The default library file is src/lib.rs.
The default executable file is src/main.rs.
Other executables can be placed in src/bin/*.rs.
Integration tests go in the tests directory (unit tests go in each file they're testing).
Examples go in the examples directory.
Benchmarks go in the benches directory.

Comments and Documenting the code
Comments and Documenting the code
// Line comments /* Block comments */

Nested block comments are supported.

Always avoid block comments, Use line comments instead.

/// Line comments; document the next item /** Block comments; document the next item */ //! Line comments; document the enclosing item /*! Block comments; document the enclosing item !*/
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Learning Rust»

Look at similar books to Learning Rust. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Learning Rust»

Discussion, reviews of the book Learning Rust and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.