前言

创建模板

➜  IdeaProjects cargo new emo_template --lib
     Created library `emo_template` package
[package]
name = "emo_template" #改这个
version = "0.1.0"
edition = "2021"
authors = ["Kali-Team <[email protected]>"]
include = ["LICENSE", "Cargo.toml", "src/**/*.rs"]
# See more keys and their definitions at <https://doc.rust-lang.org/cargo/reference/manifest.html>

[workspace]
members = ["."]

#<https://github.com/johnthagen/min-sized-rust>
[profile.release]
opt-level = "z"     # Optimize for size.
lto = true          # Enable Link Time Optimization
codegen-units = 1   # Reduce number of codegen units to increase optimizations.
panic = "abort"     # Abort on panic
strip = true        # Automatically strip symbols from the binary.

[profile.dev.package."*"]
opt-level = 3
[profile.test]
opt-level = 3
lto = "thin"

[profile.bench]
lto = true
codegen-units = 1
opt-level = 3

[dependencies]
# Generated by Cargo
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here <https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html>
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

.idea/
#!/bin/sh
# 执行 fmt 脚本,如果不正确需要将退出码设为非零
cargo clippy --workspace --all-features --all-targets -- -D warnings --allow deprecated
cargo fmt --all

# 获取上面脚本的退出码
exitCode="$?"
exit $exitCode

启用该项目作为模板

参考

https://github.com/emo-crab/rust-template

Powered by Kali-Team