Coproduct
generic coproduct types for Rust with minimal overhead
Install / Use
/learn @joonazan/CoproductREADME
Coproduct
Have you ever found yourself in a situation where you'd like to have two enums where only a few variants differ? Usually that involves a lot of duplication and boilerplate. Not any more! Coproducts allow you to describe them and convert between them effortlessly!
use coproduct::{Coproduct, MkUnion, Union};
#[derive(Debug)]
struct A;
#[derive(Debug)]
struct B;
#[derive(Debug)]
struct C;
#[derive(Debug)]
struct D;
type ABC = MkUnion!(A, B, C);
fn main() {
let abc: Coproduct<ABC> = Coproduct::inject(A);
let abcd: Coproduct<Union<D, ABC>> = abc.embed();
println!("{:?}", abcd);
}
Find out more in the documentation.
Related Skills
node-connect
349.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
