본문 바로가기
코딩 · 개발원문 · prompts.chat

Rust 라이브러리 크레이트 설계 가이드

Rust 라이브러리 크레이트의 API 설계, 에러 처리, 문서화 및 배포 기준을 제공합니다.

원제 · Rust Library Crate taste

추천 툴
코딩 에이전트형식 기준 추천

프롬프트 원문

# Rust Library Crate taste of a maintainer who publishes reusable crates
- Keep the public API small and re-export the important types from the crate root. Confidence: 0.85
- Define one error enum per crate with `thiserror`, and never return `anyhow::Error` from a library. Confidence: 0.90
- Mark public enums and config structs `#[non_exhaustive]` when new variants or fields are likely. Confidence: 0.80
- Accept flexible inputs like `impl AsRef<str>` or `impl Into<String>` and return concrete types. Confidence: 0.80
- Use the builder pattern for types with more than a few optional settings. Confidence: 0.80
- Put optional integrations behind additive cargo features; never make a feature remove functionality. Confidence: 0.90
- Keep the default feature set minimal and support `no_std` when the domain allows it. Confidence: 0.70
- Gate `serde` derives behind a `serde` feature instead of making it a hard dependency. Confidence: 0.85
- Declare `rust-version` in Cargo.toml and test the MSRV in CI. Confidence: 0.85
- Run `cargo clippy -- -D warnings`, `cargo fmt --check` and `cargo test --all-features` on every PR. Confidence: 0.90
- Check semver breakage with `cargo-semver-checks` before each release. Confidence: 0.85
- Write doc comments with runnable examples on every public item; doctests are part of the test suite. Confidence: 0.90
- Add `#![deny(missing_docs)]` and `#![forbid(unsafe_code)]` unless the crate truly needs unsafe. Confidence: 0.80
- When unsafe is needed, wrap it in a tiny module with `// SAFETY:` comments and run Miri in CI. Confidence: 0.85
- Implement common traits like `Debug`, `Clone`, `PartialEq` and `Default` on public types where they make sense. Confidence: 0.85
- Make public types `Send` and `Sync` when possible and assert it in a test. Confidence: 0.75
- Avoid forcing an async runtime on users; keep core logic runtime-agnostic. Confidence: 0.80
- Add property tests with `proptest` for parsers and encoders. Confidence: 0.75
- Benchmark hot paths with `criterion` before claiming performance improvements. Confidence: 0.75
- Release with `cargo-release` or release-plz and keep a CHANGELOG.md in Keep a Changelog format. Confidence: 0.80
- Dual-license under MIT OR Apache-2.0 to match the Rust ecosystem. Confidence: 0.80

출처 · prompts.chat 공개 프롬프트 모음 · 작성 Fatih Kadir Akın — CC0(저작권 포기)로 공개된 원문을 그대로 싣습니다. 한국어 제목 · 설명은 AI 번역이며, 실행 결과는 아직 없습니다.

같은 분야 프롬프트 코딩 · 개발

더 보기 ›