Skip to content

Releases: greyblake/kinded

Kinded v0.5.0 Release Notes

03 Feb 19:55

Choose a tag to compare

What is kinded?

Kinded is a Rust procedural macro that generates a companion "kind" enum with the same variants as your original enum but without the associated data.

New Features

skip_derive attribute

Opt out of default trait implementations when you need custom behavior or want to avoid conflicts with other derives.

use kinded::Kinded;

#[derive(Kinded)]
#[kinded(skip_derive(Display, FromStr))]
enum Status {
    Active,
    Inactive,
}

// Now you can implement Display and FromStr manually

Available traits to skip: Display, FromStr, From, Clone, Copy, Debug, PartialEq, Eq.

attrs attribute for generated enum

Pass extra attributes to the generated kind enum, useful for integrating with serde and other derive macros.

use kinded::Kinded;
use serde::{Serialize, Deserialize};

#[derive(Kinded)]
#[kinded(attrs(derive(Serialize, Deserialize), serde(rename_all = "snake_case")))]
enum Beverage {
    Coffee(String),
    Tea { flavor: String },
    Water,
}

// BeverageKind now has Serialize/Deserialize with snake_case naming

Per-variant attrs attribute

Apply attributes to individual kind variants for fine-grained control.

use kinded::Kinded;
use serde::{Serialize, Deserialize};

#[derive(Kinded)]
#[kinded(attrs(derive(Serialize, Deserialize)))]
enum Priority {
    #[kinded(attrs(serde(rename = "p0")))]
    Critical,
    #[kinded(attrs(serde(rename = "p1")))]
    High,
    Normal,
    Low,
}

const fn kind() method

The kind() method is now const fn, enabling use in const contexts.

use kinded::Kinded;

#[derive(Kinded)]
enum Direction {
    North,
    South,
    East,
    West,
}

const NORTH_KIND: DirectionKind = Direction::North.kind();

const fn is_vertical(dir: &Direction) -> bool {
    matches!(dir.kind(), DirectionKind::North | DirectionKind::South)
}

Upgrading

Update your Cargo.toml:

[dependencies]
kinded = "0.5"

v0.3.0

09 Aug 18:06

Choose a tag to compare

Changes

  • [BREAKING] - Make ::all() function return an array instead of vector.

v0.2.0

06 Aug 09:46

Choose a tag to compare

Changes

  • Add Kind trait.

v0.1.1

05 Aug 19:54

Choose a tag to compare

Changes

  • Add ::all() to the kind type to iterate over all kind variants
  • Generate customizable implementation of Display trait
  • Generate implementation of FromStr trait

v0.0.3

04 Aug 22:45

Choose a tag to compare

Changes

  • Make the generated kind() function public

v0.0.2

04 Aug 22:26

Choose a tag to compare

Changes

  • Support enums with generics

v0.0.1

04 Aug 16:16

Choose a tag to compare

Very initial release.