Quiz: บทที่ 1 - Getting Started
คำถามที่ 1
คำสั่งใดใช้ตรวจสอบว่า Rust ติดตั้งสำเร็จ?
A. rust --version
B. rustc --version
C. cargo version
D. rust-check
ดูเฉลย
B. rustc --version
rustc คือ Rust compiler ส่วน cargo --version ก็ใช้ได้เช่นกัน
คำถามที่ 2
Cargo คืออะไร?
A. Text editor สำหรับ Rust
B. Rust compiler
C. Package manager และ build tool
D. Testing framework
ดูเฉลย
C. Package manager และ build tool
Cargo ทำหน้าที่:
- จัดการ dependencies
- Build โปรเจกต์
- รัน tests
- สร้าง documentation
คำถามที่ 3
คำสั่งใดสร้างโปรเจกต์ Rust ใหม่?
A. cargo init project
B. cargo new project
C. rustc new project
D. rust create project
ดูเฉลย
B. cargo new project
cargo newสร้างโฟลเดอร์ใหม่cargo initสร้างในโฟลเดอร์ปัจจุบัน
คำถามที่ 4
ไฟล์ใดเก็บ dependencies ของโปรเจกต์?
A. main.rs
B. Cargo.lock
C. Cargo.toml
D. package.json
ดูเฉลย
C. Cargo.toml
Cargo.toml= ประกาศ dependenciesCargo.lock= lock versions ที่ใช้จริง
คำถามที่ 5
คำสั่งใดตรวจสอบโค้ดโดยไม่ build?
A. cargo run
B. cargo build
C. cargo test
D. cargo check
ดูเฉลย
D. cargo check
cargo check เร็วกว่า cargo build เพราะไม่สร้าง binary