Rust is made up of the following core components

  • Language specification
  • The compiler
  • Core library
  • The standard library
  • A package manager

Language specification

The Rust language specification is mainly composed of The Rust Reference and RFC documents.

Rust language Reference

The Rust Language Reference is maintained by the official team and consists of three categories

  • A description of the structure and usage of each language.
  • Description of memory models, concurrency models, linking, debugging, and so on.
  • Fundamentals and references that influence language design.

This document is informal and normative and can be used as a reference

The RFC document

Rust introduces a standardized RFC process. RFC documentation is a complete technical solution that covers the design intent, detailed design, advantages and disadvantages of a language feature. To sum up: THE RFC is equivalent to a draft.

The compiler

The official Rust compiler is RUSTC. Responsible for treating Rust source code as executable files or other class library files (.a,.so,.lib,.dll, etc.).

Rustc has the following characteristics

  • rustcIs a cross-platform application that supports UniX-like platforms such as UNIX/Linux as well as Windows
  • rustcCross-compilation is supported to compile applications and libraries on the current platform that can run on other platforms.
  • rustcLLVM is used as a compiler back end, with good code generation and optimization techniques, supporting multiple target platforms.
  • rustcDeveloped in the Rust language and included in the Rust language source code.
  • rustcThe lexical analysis and static type checking of Rust source code were carried out, and the code was finally translated into LLVM IR.
  • rustcThe error messages are very friendly and detailed and are a great mentor to developers

Core library

The Rust syntax is provided by both the core library and the standard library. The Rust core library is the foundation of the standard library. The core library defines the core of the Rust language. By introducing #! At the top of the module. [no STD] to use the core library, there is some overlap between the core library and the standard library functions, including the following sections:

  • Basic traits such asCopyDebug,Display,OptionAnd so on.
  • Basic primitive types such as:bool,char,i8/u8,i16/u16,i32/u32,i64/u64,isize/usize,f32/f64,str,array,slice,tuple,pointerAnd so on.
  • Common functional data types that meet common functional requirements such asString,Vec,HashMap,Rc,Arc,BoxAnd so on.
  • Common macro definitions such as:println!,assert!,panic!,vec!And so on.

When doing embedded development, a core library is a must.

The standard library

The Rust standard library provides the basic platform and cross-platform support required for application development. The standard library contains something like this:

  • Basic traits, primitive data types, functional data types, and common macros are the same as the core library, along with an API that is almost identical to the core library.
  • Concurrency, I/O, and runtime. Such as thread modules, channel types for messaging,Sync,traitAnd other concurrent modules, files, TCP, UDP, pipes, sockets and other common I/O
  • Platform abstraction. The OS module provides many interactive functions of the operating environment, including program parameters, environment variables and directory navigation. The path module encapsulates platform-specific rules for handling file paths.
  • Low-level operation interfaces, such as:std::mem,std::ptr,std:::intrinsicsEtc., operating system memory, Pointers, call compiler native functions.
  • Optional and error handling types Option and Result, various iterators, etc.

A package manager

A package (CREAT) is the result of compiling rs files organized by certain rules. Packages are the basic compilation unit of Rust code, that is, shared code.

The third-party packages that the Rust community makes public are centrally located at Nostalgic.io, and their documentation is automatically published on the docs.

Rust’s package management tool is Cargo. Cargo is not limited to package management; it also provides a standard workflow for the Rust ecosystem. Cargo is able to manage the entire workflow, from creating projects, running unit and inositol tests, building release link libraries, running executables, and more. Cargo is a great convenience for developers.

# Rust learning