算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
rust-trait-api-design【设计与创意】Design and review Rust trait APIs, generic bounds, dispatch models, and conversion contracts for clear public interfaces. Use when designing, refactoring, or reviewing traits, generics, trait objects, associated types, impl Trait, From/TryFrom, AsRef, Borrow, or crate APIs.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this skill to make Rust APIs generic where useful, concrete where simpler, and object-safe when dynamic dispatch is part of the design. Optimize for the smallest capability contract that callers and implementors can understand.
dyn Trait for heterogeneous values, plugin-like extension points, or runtime
dispatch.where clauses when
bounds are long or involve associated types.From, TryFrom, AsRef, AsMut,
Borrow, ToOwned, and Cow.impl Trait or a named generic for parameters when callers should
pass many concrete types.impl Trait when hiding one concrete return type. Return Box<dyn Trait> when the concrete type varies at runtime.From for infallible conversions and TryFrom for fallible
conversions. Implementing these gives callers Into and TryInto.AsRef for cheap reference-to-reference conversion. Use Borrow only
when borrowed and owned forms have equivalent Eq, Hash, and Ord
behavior.Copy bounds unless the algorithm semantically requires bitwise copy.Read references/trait-api-patterns.md when choosing between generics and
dyn Trait, or when public traits fail object-safety checks.
Before making a public trait object-safe, check:
Self unless constrained with where Self: Sized.&dyn Trait, Box<dyn Trait>, or
Arc<dyn Trait + Send + Sync>.&Vec<T> because it only needs iteration.String and immediately borrows it as &str.Into directly instead of From.async-trait is used in a public trait without checking whether native
async fn in traits, trait-variant, or boxed futures fit the dispatch and
Send needs better.