https://github.com/tushcmd/rust-base
Rust Programming base code layout
https://github.com/tushcmd/rust-base
Last synced: 3 months ago
JSON representation
Rust Programming base code layout
- Host: GitHub
- URL: https://github.com/tushcmd/rust-base
- Owner: tushcmd
- Created: 2024-06-27T17:21:56.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-07-01T21:30:35.000Z (11 months ago)
- Last Synced: 2025-01-31T19:14:10.854Z (4 months ago)
- Language: Rust
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rust-base code layout
This is an opinionated way to start a rust project
## Initialise the project
Initialise a rust project in the current folder
```sh
cargo init
```This is how `cargo.toml` looks like initially.
`cargo.toml` - This is called a manifest, and it contains all of the metadata that Cargo needs to compile your package.```toml
[package]
name = "rust-base"
version = "0.1.0"
edition = "2021"[dependencies]
```### Dependencies
Dependencies to add
First we add thiserror for error handling under dependencies```toml
thiserror = "1"
```If you intend to use async add tokio
```toml
tokio = { version = "1", features = ["full"] }
```If you are doing a command line interface you may use
```toml
clap = { version = "4", features = ["cargo"] }
```### Dev dependencies
Add dev dependencies
anyhow - good for unit tests, examples and benchmarks```toml
[dev-dependencies]
anyhow = "1"
```### Full `cargo.toml` file
```toml
[package]
name = "rust-base"
version = "0.1.0"
edition = "2021"[dependencies]
tokio = { version = "1", features = ["full"] }[dev-dependencies]
anyhow = "1"
```Now run
```sh
cargo build
```Then
```sh
cargo run
```Or
```sh
./target/debug/rust-base
```