Skip to content

Commit

Permalink
Finalize CHANGELOG.md and documentation for 0.2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 committed Jan 13, 2020
1 parent 3bef0b8 commit cd2a1ed
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## Unreleased
## 0.2.0 (2020-01-13)

* Allow variants to be skipped using `#[evt(skip)]`.
* ***Breaking:*** `#[evt(..)]` specifies the attributes to attach to the generated type (previously `#[evt_attr(..)]`).
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "enum_variant_type"
version = "0.1.0"
version = "0.2.0"
authors = ["Azriel Hoh <[email protected]>"]
edition = "2018"
description = "Generates types for "
description = "Generates types for each enum variant and conversion trait impls."
repository = "https://github.com/azriel91/enum_variant_type"
documentation = "https://docs.rs/enum_variant_type/"
readme = "README.md"
keywords = ["typename", "type", "name"]
keywords = ["enum", "variant", "type"]
license = "MIT OR Apache-2.0"

[lib]
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,37 @@ Proc macro derive to generate structs from enum variants.

This is a poor-man's implementation of <https://github.com/rust-lang/rfcs/pull/2593>.

```toml
[dependencies]
enum_variant_type = "0.2.0"
```

## Examples

```rust,edition2018
use std::convert::TryFrom;
use enum_variant_type::EnumVariantType;
#[derive(Debug, EnumVariantType, PartialEq)]
pub enum MyEnum {
/// Unit variant.
#[evt_attrs(derive(Clone, Copy, Debug, PartialEq))]
#[evt(derive(Clone, Copy, Debug, PartialEq))]
Unit,
/// Tuple variant.
#[evt_attrs(derive(Debug, PartialEq))]
#[evt(derive(Debug, PartialEq))]
Tuple(u32, u64),
/// Struct variant.
#[evt_attrs(derive(Debug))]
#[evt(derive(Debug))]
Struct {
field_0: u32,
field_1: u64,
},
/// Skipped variant.
#[evt(skip)]
Skipped,
}
// Now you can do the following:
use std::convert::TryFrom;
let unit: Unit = Unit::try_from(MyEnum::Unit).unwrap();
let tuple: Tuple = Tuple::try_from(MyEnum::Tuple(12, 34)).unwrap();
let named: Struct = Struct::try_from(MyEnum::Struct { field_0: 12, field_1: 34 }).unwrap();
Expand Down
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
//!
//! This is a poor-man's implementation of <https://github.com/rust-lang/rfcs/pull/2593>.
//!
//! ```toml
//! [dependencies]
//! enum_variant_type = "0.2.0"
//! ```
//!
//! # Examples
//!
//! ```rust,edition2018
//! use std::convert::TryFrom;
//!
//! use enum_variant_type::EnumVariantType;
//!
//! #[derive(Debug, EnumVariantType, PartialEq)]
Expand All @@ -32,6 +35,7 @@
//! }
//!
//! // Now you can do the following:
//! use std::convert::TryFrom;
//! let unit: Unit = Unit::try_from(MyEnum::Unit).unwrap();
//! let tuple: Tuple = Tuple::try_from(MyEnum::Tuple(12, 34)).unwrap();
//! let named: Struct = Struct::try_from(MyEnum::Struct { field_0: 12, field_1: 34 }).unwrap();
Expand Down

0 comments on commit cd2a1ed

Please sign in to comment.