접근
자격 증명:
- 사용자:
ferris - 비밀번호: (저장됨)
/root/.cloudzy-creds)
서버에 루트 권한으로 SSH 접속한 후 Rust 사용자로 전환:
su - ferris
중요한 디렉터리
/home/ferris/.cargo/→ 화물 바이너리 (cargo설치된 상자)/home/페리스/.rustup/→ Rust 툴체인 및 구성 요소/home/페리스/→ 작업 공간 (프로젝트가 여기에 있습니다)
유용한 명령어
설치 확인:
cargo --version
rustc --version
Rust 업데이트:
rustup update
추가 도구(예: 린터) 추가/업데이트:
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