Rust bit by bit: one stop learning standard library (1) – how to start



An excellent programming language should not only have basic language specifications, but also be supported by high-quality standard library. Rust provides a set of standard library to broaden the ecology of rust. The standard library provides common core types, collections, multithreading, macros and other tools, so that it is convenient to use rust for development


The standard library contains four major components: basic types, common modules, standard macros and keywords. Although the basic types are called “basic types”, they still belong to the rust type system and are not essentially different from user-defined types. The standard library provides many modules, some of which are associated modules of basic types, and they have the same name as basic types, It usually contains some auxiliary functions related to basic types, such as key special values, common tools and methods, etc. in addition, it also includes some common collection classes, platform related abstractions and I / O

The standard library defines prelude, most of which are very common traits. Beginners can start from these core traits

How to view documents

I think the core of learning standard library documents and even any materials is to master themmotivationandstructureThe motivation to master the standard library is to find out two things: understand what problems each module needs to solve, understand the ideas of the module to solve this problem, and be sure to read the document with the problem. After browsing the structure of the standard library, you will find that most modules contain these five parts: basic concept, implementation method, implementation trail, Auto trait (trait implemented by rust language for this type), blank trait (trait implemented by this type because it meets the trait limit)

If you have mastered the motivation and structure, you can go further into the source code to learn the standard library if necessary. The key to this step is to consider the commonalities and characteristics between rust and other language standard libraries in combination with rust’s programming ideas. The knowledge points that may be involved include: object-oriented, generic, trait, ownership, life cycle, unsafe, etc

Attached is my mind map for reference and discussion

Rust bit by bit: one stop learning standard library (1) - how to start

reference material

Recommended Today

Less sass SCSS stylus of CSS preprocessor

Let’s ask ourselves a question: why do we need a preprocessor?The answer is self-evident, that is, CSS itself has some disadvantages: The syntax is not strong enough to be written nested, resulting in unclear style logic in the project. There is no variable and logical reuse mechanism. When it is necessary to reuse code, you […]