
Modules & Packages
Crate structure, modules (mod), pub visibility, use keyword, Cargo.toml, workspaces
1Which file is the root of a library crate in Rust?
Which file is the root of a library crate in Rust?
คำตอบ
The src/lib.rs file is the conventional entry point for a Rust library. Cargo automatically recognizes it as the library crate root. This file declares the public modules of the library and defines the API exposed to crate users.
2Which keyword is used to declare a submodule in a Rust file?
Which keyword is used to declare a submodule in a Rust file?
คำตอบ
The mod keyword is used to declare a module. It can be followed by a block containing the module code, or simply the module name if the code is in a separate file. Cargo then automatically looks for the corresponding file.
3By default, what is the visibility of items (functions, structs, etc.) in a Rust module?
By default, what is the visibility of items (functions, structs, etc.) in a Rust module?
คำตอบ
In Rust, all items are private by default. This design decision promotes encapsulation and forces developers to be explicit about what should be publicly exposed. The pub keyword must be used to make an item accessible from outside the module.
Which syntax allows importing a type and using it without a path prefix?
What does the crate:: path prefix mean at the beginning of an import?
+15 คำถามสัมภาษณ์
หัวข้อสัมภาษณ์ Rust อื่นๆ
Rust Basics
Ownership & Borrowing
Structs & Enums
Error Handling
Collections
Traits
Generics
Lifetimes
Iterators & Closures
Smart Pointers
Concurrency Basics
async/await
Testing
Cargo & Ecosystem
Pattern Matching
Macros
Serde & Serialization
Unsafe Rust
Advanced Traits
Advanced Lifetimes
Type System
Tokio & Async I/O
Performance Optimization
Memory Management
Web Frameworks
Database Integration
Rust Design Patterns
เชี่ยวชาญ Rust สำหรับการสัมภาษณ์ครั้งถัดไป
เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์
เริ่มใช้ฟรี