SkillAgentSearch skills...

Coproduct

generic coproduct types for Rust with minimal overhead

Install / Use

/learn @joonazan/Coproduct
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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

View on GitHub
GitHub Stars4
CategoryDevelopment
Updated6mo ago
Forks0

Languages

Rust

Security Score

62/100

Audited on Sep 29, 2025

No findings