rust-patterns
慣用的なRustパターン、所有権、エラー処理、トレイト、並行処理、および安全で高性能なアプリケーションを構築するためのベストプラクティス。
Original · translation is not supported for this source languageTarget: Target not categorized. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original Japanese text
Topics in the source
- Rust 開発パターン
- 使用場面
- 動作原理
- コア原則
- 1. 所有権と借用
- 柔軟な所有権のための Cow の使用
- エラー処理
- Result と ? を使用する——本番環境では unwrap() を絶対に使わない
安全で高性能かつ保守性の高いアプリケーションを構築するための慣用的なRustパターンとベストプラクティス。 新しいRustコードを書く場合 Rustコードをレビューする場合 既存のRustコードをリファクタリングする場合 クレート構造とモジュールレイアウトを設計する場合 このスキルは6つの重要な領域で慣用的なRustの規約を強制する:コンパイル時のデータ競合防止のための所有権と借用、ライブラリではthiserror、アプリケーションではanyhowを使用したResult/?エラー伝播、不正な状態を表現不可能にする列挙型と完全パターンマッチング、ゼロコスト抽象化のためのトレイトとジェネリクス、Arc >、チャンネル、async/awaitによる安全な並行処理、ドメインで整理された最小化されたpubインターフェース。 Rustの所有権システムはコンパイル時にデータ競合とメモリエラーを防ぐ。 | イディオム | 説明 | |-------|-------------| | 借用、クローンではなく | 所有権が必要でなければ &T を渡し、クローンしない | | 不正な状態を表現不可能にする | 列挙型を使用して有効な状態のみをモデル化する | | unwrap() より ? | エラーを伝播し、ライブラリ/本番コードでパニックしない | | 検証より解析 | 境界で非構造化データを型付き構造体に変換する | | 型安全のためのNewtype | 基本型をnewtypeでラップして引数の取り違えを防ぐ | | ループよりイテレーターを優先 | 宣言的なチェーンはより明確で通常より高速 | | Resultに #[mustuse] を使用 | 呼び出し元が戻り値を処理することを保証する | | 柔軟な所有権のために Cow を使用 | 借用で十分な場合にアロケーションを避ける | | 完全マッチング | ビジネスクリティカルな列挙型でワイルドカード を使わない | | pub インターフェースを最小化 | 内部APIには pub(crate) を使用 | 覚えておくこと:コンパイルが通れば、おそらく正しい——ただし unwrap() を避け、unsafe を最小化し、型システムを活用することが前提。
- Source repository
- affaan-m/ECC
- Source file
- docs/ja-JP/skills/rust-patterns/SKILL.md
- Fixed revision
- d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:49.636Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.