50% off 所有套餐限时优惠,起价 $2.48/mo
Rust

Rust

Rust 是一门系统级编程语言。内存安全、无垃圾回收、运行速度媲美 C,并在 Stack Overflow 连续八年荣获最受喜爱语言称号。AWS、Microsoft、Cloudflare、Discord 以及 Linux 内核均在使用。如今已成为高性能系统软件的首选语言。

Version

Latest

Operating System

Ubuntu Server 24.04 LTS

Min. RAM

1 GB

IP Types

IPV4,IPV6

Access

Credentials:

  • User: ferris
  • Password: (stored in /root/.cloudzy-creds)

以 root 身份 SSH 服务器,然后切换到 Rust 用户:

su - ferris

Important Directories

  • /home/ferris/.cargo/ → Cargo binaries (cargo, installed crates)
  • /home/ferris/.rustup/ → Rust 工具链与组件
  • /home/ferris/ → 你的工作区(项目存放于此)

Useful Commands

Verify installation:

cargo --version
rustc --version

Update Rust:

rustup update

添加或更新额外工具(如 linter):

rustup component add clippy

Uninstall Rust:

rustup self uninstall

构建项目:

cargo build

运行项目:

cargo run

Run tests:

cargo test

为项目生成文档:

cargo doc --open

将库发布到 crates.io:

cargo publish

一个简单的 Rust 应用

创建新项目:

cargo new hello-rust
cd hello-rust

运行默认程序:

cargo run

通过 CLI 添加依赖:

cargo add ferris-says

然后构建(Cargo 会自动安装依赖):

cargo build

此操作还会生成 Cargo.lock (依赖版本锁定文件)。

Edit src/main.rs:

use ferris_says::say;
use std::io::{stdout, BufWriter};


fn main() {
    let stdout = stdout();
    let message = String::from("Hello fellow Rustaceans!");
    let width = message.chars().count();


    let mut writer = BufWriter::new(stdout.lock());
    say(&message, width, &mut writer).unwrap();
}

Run it:

cargo run

更多开发工具

Related apps.

立即部署 Rust。 From $2.48/mo.