50% 折扣 所有计划,时间有限。开始于 $2.48/mo
锈

访问凭证: 用户:ferris 密码:(存储在 /root/.cloudzy-creds 中)以 root 身份 SSH 到服务器,然后切换到 Rust 用户:su - ferris 重要目录 /home/ferris/.cargo/ \u2192 Cargo 二进制文件(cargo、已安装的板条箱) /home/ferris/.rustup/ \u2192 Rust 工具链和组件 /home/ferris/ \u2192 你的工作区(项目在这里)有用的命令验证安装:cargo --version rustc --version Update Rust:rustup [...]

版本

最新的

操作系统

Ubuntu 服务器 24.04 LTS

分钟。内存

1 GB

IP类型

IPV4,IPV6

使用权

证书:

  • 用户: ferris
  • 密码:(存储在 /root/.cloudzy-creds)

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

su - ferris

重要目录

  • /home/ferris/.cargo/ → 货物二进制文件 (cargo,已安装的板条箱)
  • /home/摩天轮/.rustup/ → Rust 工具链和组件
  • /home/摩天轮/ → 您的工作空间(项目在这里)

有用的命令

验证安装:

cargo --version
rustc --version

更新铁锈:

rustup update

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

rustup component add clippy

卸载 Rust:

rustup self uninstall

构建您的项目:

cargo build

运行你的项目:

cargo run

运行测试:

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 (依赖版本锁定文件)。

编辑 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();
}

运行它:

cargo run

立即部署 Rust。 每月 2.48 美元起。