"Yiya Neng Pao Jiu Xing" is my personal solo podcast, a draft version of a web worker podcast. It focuses on casual and fast consumption, and if you are interested in the topics I talk about and want to have a serious discussion in the web worker podcast, feel free to interact with me.
- Node can use
- Rust uses Cargo
Cargo not only manages packages but also runs tests, unlike vitest/jest/mocha/chai in Node. It can also build your documentation, publish Rust libraries, and run code similar to
npm run start.
The main package file
Cargo.toml is similar to
Cargo.tomlis a configuration file in the Rust language used to describe and manage project metadata and dependencies.
- In a Rust project, the
Cargo.tomlfile is located in the root directory of the project. It uses the TOML (Tom's Obvious, Minimal Language) format to describe the project's configuration information.
- TOML is a lightweight format for configuration files created by Tom Preston-Werner. It is designed to be easy to read and write while maintaining a concise and clear syntax.
- TOML aims to make configuration files easy to write and read while maintaining a concise and clear syntax. It has been widely used in the Rust community and has become one of the commonly used configuration file formats in Rust projects.
Similar to YAML.
- Builds the project.
- Can be published to an internal registry in Rust, similar to npm.
- There is only one option in Rust, unlike Node which has different options. There is a Rust fork called "crab".
cargo docis a command-line tool in the Rust language used to generate documentation for projects. It generates an HTML-formatted documentation website based on comments and doc comments in the project, allowing developers to easily view and browse the project's documentation.
Documentation is extracted from code comments.
Continuing to look at crates.io, every project has a readme and most of them are clear. Generating documentation is easy.
Similar to JSDoc, but easier than JSDoc, although it requires learning the syntax. (practice.rs's comments-docs)
Rust is fully typed, similar to TypeScript's static typing, and also has generics. Experience in TypeScript can be applied to Rust.
The position where the
Rust does not have try..catch, and exception handling is done through pattern matching, somewhat similar to switch.
In summary, error handling in Rust uses pattern matching, which is safer and more reliable. Compared to the traditional try-catch mechanism, it can capture potential errors at compile time and provide better code readability and maintainability.
a.b.c. In Rust, double colons
:: are used.
What is different?
- The joy of technical choices, using what Rust provides is enough, and many things do not need to be chosen.
There are 13 basic types, including a large number of integer types. There are two different flow types. We can continue to talk about them later, such as types, structures, and variables.