← スキル一覧に戻る

rdos-rust-patterns
by thrashr888
A cli-based QDOS clone re-written in rust
⭐ 7🍴 0📅 2026年1月19日
SKILL.md
name: rdos-rust-patterns description: Rust best practices and overall approach for R-DOS development. Use when writing Rust code, implementing features, handling errors, or structuring code in the R-DOS codebase.
R-DOS Rust Patterns
R-DOS is a retro DOS-style file manager TUI in Rust using ratatui. It recreates Q-DOS II (1991, Gazelle Systems) with modern Rust patterns.
Error Handling
// Use Result for fallible operations
pub fn load_data(&mut self) -> Result<(), String> {
let output = Command::new("tool")
.output()
.map_err(|e| format!("Failed to run: {}", e))?;
if !output.status.success() {
return Err(String::from_utf8_lossy(&output.stderr).to_string());
}
Ok(())
}
State Types
Always derive common traits and use Default:
#[derive(Debug, Clone, Default)]
pub struct MyState {
pub view: MyView,
pub items: Vec<MyItem>,
pub selected: usize,
pub error: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum MyView {
#[default]
List,
Detail,
Error,
}
External Processes
Suppress stdout/stderr for background processes:
use std::process::{Command, Stdio};
Command::new("player")
.arg(&file_path)
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn();
File Operations
Pattern for sibling file detection:
pub fn detect_siblings(&mut self) {
let Some(ref file_path) = self.file_path else { return };
let Some(parent) = file_path.parent() else { return };
let mut siblings: Vec<PathBuf> = std::fs::read_dir(parent)
.into_iter()
.flatten()
.filter_map(|e| e.ok())
.map(|e| e.path())
.filter(|p| p.is_file() && is_valid_file(p))
.collect();
siblings.sort();
self.current_index = siblings.iter().position(|p| p == file_path).unwrap_or(0);
self.sibling_files = siblings;
}
Documentation
//! Module-level doc comment
//!
//! Extended description.
/// Function documentation
pub fn my_function() { ... }
Quality Checks
Run before committing:
cargo fmt -- --check
cargo clippy -- -D warnings
cargo test
Avoid
- Sentinel values (use Option)
- Ignoring clippy warnings
- Hardcoded paths (use config or cwd)
- Blocking the main thread (use background threads for long operations)
スコア
総合スコア
55/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
1ヶ月以内に更新
+10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
レビュー
💬
レビュー機能は近日公開予定です


