Rust

Articles in Section

Аргументы за/против Rust

Плюсы Rust:

Минусы:

  • Его сложно учить, много синтаксиса
  • Перестроение мозгов: дуализм результата (enums Result), метки lifecycle, traits
  • Язык молодой, экосистема беднее чем у Python, тем более чем у C++, сообщество меньше

Сравнения

Golang, хороший-плохой-злой: https://habr.com/ru/companies/vk/articles/353790/

Видеокурсы

Задачи по программированию

Rust Tools

External links:

rustup component add rustfmt 
rustup component add rust-src
  • Install Cargo-watch to rerun code upon save:
cargo install cargo-watch
git clone https://github.com/AstroNvim/AstroNvim ~/.config/nvim
nvim +PackerSync

# After install use commands:
:LspInstall rust -> rust-analyzer
:TSInstall rust
  • Neovide GUI upgrade on Astro Vim
git clone https://github.com/neovide/neovide
cd neovide
cargo build --release
  • EVCXR or iRUST REPL
cargo install evcxr_repl
cargo install irust
cargo install --locked bacon
bacon test # run from project folder 

VSCode Extensions for Rust

  • CodeLLDB
  • Dependi (бывш crates) - сообщает, если пакеты устарели

VSCode Settings

(For CodeLLDB) Allow breakpoints everywhere: "debug.allowBreakpointsEverywhere": true cargo check: поменять check на clippy: "rust-analyzer.check.command": "clippy"

Rust Prelude

Rust has a Prelude - a set of libraries included in every project. See current libs included in Prelude

Allow Unused

Turn off noise about unused objects while learning with a crate attribute:

#![allow(unused)] // silence unused warnings while learning
fn main() {}

User input

std::io::stdin library is used to get user input from standard input stream. Not included in Prelude:

use std:io

let mut guess = String::new();
io::stdin().read_line(&mut guess).expect("Failed to load");

.expect handles Err variant of read_line function, crashing the program with the defined error message.