Cargo
Use Cargo for managing projects.
cargo new test_project // create project with binary file src/main.rs
// OR
cargo new test_project --lib // create project with library file src/lib.rs
cd test_projectSource code is in src folder.
cargo build # build project for debug, do not run
cargo run # build & run project
cargo check # fast compiling
cargo build --release # slow build with optimizations for speed of release versionDocumentation of methods & traits used in code can be compiled an opened in browser with Cargo command:
cargo doc --openCargo Examples
Create “examples” folder beside the “src” folder. Create a file named, for example, “variables.rs” and place some test code in the folder. Then in the project root folder run:
cargo run --example variablesPanic Response
В ответ на панику, по умолчанию программа разматывает стек (unwinding) - проходит по стеку и вычищает данные всех функций. Для уменьшения размера можно просто отключать программу без очистки - abort. Для этого в файле Cargo.toml надо добавить в разделы [profile]:
[profile.release]
panic = 'abort'Important Cargo libs
Секция подробностей работы разных библиотек постепенно пополняется.
- Tokio - async runtime
- Eyre & color-eyre - type signatures, error report handling
- Tracing - collect diagnostic info
- Reqwest - HTTP requests library, async
- Rayon - data parallelism library, without data races
- Clap - commandline passing library
- SQLX - compile-checked SQL, async
- Chrono - time/date library
- EGUI - web-gui @60FPS, runs in Webassembly
- Yew.rs - web-library like React.js