# エラー処理 (Rust) > Result、Option、unwrap、expect、?、カスタムエラー、エラーの伝播 - 18 面接問題 - Junior - [面接問題: Rust](https://sharpskill.dev/ja/technologies/rust/interview-questions.md) ## 1. 値が存在する場合と存在しない場合を表す Rust の型はどれですか? **回答** Option は、値を保持する Some(T) か、値の不在を示す None のいずれかになる enum です。この型は他の言語に存在する null 値を置き換え、値が存在しない場合を明示的に処理することを開発者に強制するため、実行時の null ポインタエラーを防ぎます。 ## 2. 成功するか、エラーで失敗するかのどちらかになる操作を表す Rust の型はどれですか? **回答** Result は 2 つのバリアントを持つ enum です。成功時には戻り値を保持する Ok(T)、失敗時にはエラーを保持する Err(E) です。この型は例外を使うのではなく明示的なエラー処理を強制するため、コードがより予測可能になり、エラーがより見えやすくなります。 ## 3. unwrap() メソッドは Option に対して何をしますか? **回答** unwrap() は値が存在する場合に Some(T) に含まれる値を返します。Option が None の場合、プログラムはパニック(panic!)を起こし即座に停止します。このメソッドはプロトタイピングには便利ですが、None のケースを適切に処理しないため本番環境では避けるべきです。 ## さらに15問利用可能 - unwrap() と expect() の違いは何ですか? - Result を返す関数の中で ? 演算子は何をしますか? 無料で登録: https://sharpskill.dev/ja/login ## その他のRust面接トピック - [Rustの基礎](https://sharpskill.dev/ja/technologies/rust/interview-questions/rust-basics.md): 25問, Junior - [Ownership & Borrowing](https://sharpskill.dev/ja/technologies/rust/interview-questions/ownership-borrowing.md): 22問, Junior - [Structs & Enums](https://sharpskill.dev/ja/technologies/rust/interview-questions/structs-enums.md): 20問, Junior - [コレクション](https://sharpskill.dev/ja/technologies/rust/interview-questions/collections.md): 20問, Junior - [モジュールとパッケージ](https://sharpskill.dev/ja/technologies/rust/interview-questions/modules-packages.md): 18問, Junior - [Traits](https://sharpskill.dev/ja/technologies/rust/interview-questions/traits.md): 22問, Mid-Level - [Generics](https://sharpskill.dev/ja/technologies/rust/interview-questions/generics.md): 20問, Mid-Level - [Lifetimes](https://sharpskill.dev/ja/technologies/rust/interview-questions/lifetimes.md): 20問, Mid-Level - [Iterators & Closures](https://sharpskill.dev/ja/technologies/rust/interview-questions/iterators-closures.md): 22問, Mid-Level - [Smart Pointers](https://sharpskill.dev/ja/technologies/rust/interview-questions/smart-pointers.md): 22問, Mid-Level - [Concurrency Basics](https://sharpskill.dev/ja/technologies/rust/interview-questions/concurrency-basics.md): 20問, Mid-Level - [async/await](https://sharpskill.dev/ja/technologies/rust/interview-questions/async-await.md): 22問, Mid-Level - [Testing](https://sharpskill.dev/ja/technologies/rust/interview-questions/testing.md): 18問, Mid-Level - [Cargo & Ecosystem](https://sharpskill.dev/ja/technologies/rust/interview-questions/cargo-ecosystem.md): 18問, Mid-Level - [Pattern Matching](https://sharpskill.dev/ja/technologies/rust/interview-questions/pattern-matching.md): 18問, Mid-Level - [マクロ](https://sharpskill.dev/ja/technologies/rust/interview-questions/macros.md): 20問, Mid-Level - [Serde とシリアライゼーション](https://sharpskill.dev/ja/technologies/rust/interview-questions/serde-serialization.md): 20問, Mid-Level - [Unsafe Rust](https://sharpskill.dev/ja/technologies/rust/interview-questions/unsafe-rust.md): 20問, Senior - [高度なトレイト](https://sharpskill.dev/ja/technologies/rust/interview-questions/advanced-traits.md): 22問, Senior - [高度な lifetime](https://sharpskill.dev/ja/technologies/rust/interview-questions/advanced-lifetimes.md): 20問, Senior - [Type System](https://sharpskill.dev/ja/technologies/rust/interview-questions/type-system.md): 20問, Senior - [Tokio & Async I/O](https://sharpskill.dev/ja/technologies/rust/interview-questions/tokio-async.md): 22問, Senior - [パフォーマンス最適化](https://sharpskill.dev/ja/technologies/rust/interview-questions/performance-optimization.md): 20問, Senior - [Memory Management](https://sharpskill.dev/ja/technologies/rust/interview-questions/memory-management.md): 20問, Senior - [Web Frameworks](https://sharpskill.dev/ja/technologies/rust/interview-questions/web-frameworks.md): 22問, Senior - [Database Integration](https://sharpskill.dev/ja/technologies/rust/interview-questions/database-integration.md): 20問, Senior - [Rust デザインパターン](https://sharpskill.dev/ja/technologies/rust/interview-questions/design-patterns.md): 20問, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ja/technologies/rust/interview-questions/error-handling