Access
Credentials:
- User:
ferris - Password: (stored in
/root/.cloudzy-creds)
SSH로 서버에 root 접속 후, 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
추가 도구 설치/업데이트 (예: 린터):
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