rustup
rustup 是一个 rust 开发环境管理工具,可用于在不同的 rust 版本切换,指定目标平台等。
1 2 3 4
| # 安装 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup show rustup man cargo
|
打包为无需依赖 libc 的 fully static binaries:
1 2
| rustup target add x86_64-unknown-linux-musl cargo build --target x86_64-unknown-linux-musl --release
|
打印结构体
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #[derive(Debug)] struct User { username: String, email: String, sign_in_count: u64, active: bool, }
fn main() { let user1 = User { email: String::from("someone@example.com"), username: String::from("someusername123"), active: true, sign_in_count: 1, };
let user2 = User { email: user1.email.clone(), username: String::from("anotherusername567"), active: user1.active, sign_in_count: user1.sign_in_count, }; println!("{:?}", user1); println!("{:?}", user2); }
|