| Crates.io | polars_structpath_derive |
| lib.rs | polars_structpath_derive |
| version | 0.2.1 |
| created_at | 2025-12-20 08:12:56.999111+00 |
| updated_at | 2025-12-20 23:27:31.11329+00 |
| description | Derive macros for polars_structpath |
| homepage | |
| repository | https://github.com/jmunar/polarspath |
| max_upload_size | |
| id | 1996175 |
| size | 77,911 |
This crate provides procedural derive macros for the polars_structpath ecosystem. It automatically generates implementations of the StructPath and EnumPath traits, enabling dynamic path-based access to nested Rust structures.
polars_structpath_derive is a procedural macro crate that generates code for:
StructPath trait for structs, enabling path-based field accessEnumPath trait for enums, enabling path-based enum value access with case conversion supportThis crate is used by:
polars_structpath: The main user-facing library that re-exports these derive macros#[derive(StructPath)] or #[derive(EnumPath)] to their structs and enumsApply the #[derive(StructPath)] attribute to structs with named fields:
use polars_structpath::StructPath;
#[derive(StructPath)]
struct User {
name: String,
age: i64,
#[type_hint("struct")]
parent: Option<Parent>,
}
#[derive(StructPath)]
struct Parent {
name: String,
}
The #[type_hint] attribute can be used to provide type information for complex types like nested structs, enums, or collections.
Apply the #[derive(EnumPath)] attribute to enums:
use polars_structpath::EnumPath;
#[derive(EnumPath)]
#[enum_path(camel_case_to_upper_snake_case)]
enum Status {
Active,
Inactive,
}
The #[enum_path] attribute supports case conversion functions for mapping enum variant names to string representations.