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.
- 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.
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