Skip to content

This is library that use macro, never type (exhausitive patterns for enum variants), to make GADT (from haskell world) like structure. makes ability to use poly variants like (from Ocaml world), and/or final tagless or free monads like ways methods etc

License

Notifications You must be signed in to change notification settings

rusty-dusty-corner/poly_variants

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Poly Variants

Poly Variants is a Rust library for working with polymorphic variants, providing efficient and type-safe operations over complex enum structures. This library is aimed at developers needing flexibility and extensibility in their data structures without sacrificing safety.

Features

  • Type-safe polymorphic variants: Build and manage polymorphic data structures efficiently.
  • Flexible: Allows variants to evolve over time without losing type safety.
  • Extensible: Easily add new variants to existing structures.
  • Optimized for performance: Designed with efficiency in mind for production use.

Installation

Add poly_variants to your Cargo.toml dependencies:

[dependencies]
poly_variants = "0.1.0"

Then, in your main.rs or lib.rs, include it with:


extern crate poly_variants;

Usage

Here’s a basic example of how to use Poly Variants in your Rust project:

rust

use poly_variants::PolyVariant;

#[derive(Debug)]
enum MyVariant {
    Int(i32),
    Float(f64),
    Text(String),
}

fn main() {
    let int_variant = MyVariant::Int(42);
    let float_variant = MyVariant::Float(3.14);
    let text_variant = MyVariant::Text(String::from("Hello"));

    println!("{:?}", int_variant);
    println!("{:?}", float_variant);
    println!("{:?}", text_variant);
}

Advanced Usage

The library supports advanced use cases such as:

    Combining multiple variants into one structure
    Handling unknown variants gracefully

Refer to the documentation for more detailed examples and API references.
Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.
To contribute:

    Fork the repository.
    Create a new branch (git checkout -b feature/your-feature).
    Commit your changes (git commit -am 'Add new feature').
    Push to the branch (git push origin feature/your-feature).
    Open a pull request.

License

Poly Variants is licensed under the MIT License. See LICENSE for more information.
Contact

For questions or issues, please contact rusty-dusty-corner or open an issue directly on the GitHub repository.

vbnet


Feel free to adjust the description and examples based on the specific functionality

About

This is library that use macro, never type (exhausitive patterns for enum variants), to make GADT (from haskell world) like structure. makes ability to use poly variants like (from Ocaml world), and/or final tagless or free monads like ways methods etc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages