Skip to content

Commit

Permalink
Merge pull request #7 from kaleidawave/master
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 authored Dec 18, 2021
2 parents 2b888a7 + fc4f31d commit 9f16b02
Show file tree
Hide file tree
Showing 8 changed files with 418 additions and 189 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
on:
push:
branches:
- master
pull_request:
branches:
- '**'

name: CI

jobs:
audit:
name: Audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

fmt:
name: Rustfmt
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt

- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: clippy

- name: Install Clippy
run: rustup component add clippy

- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

coverage:
name: Coverage
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: tarpaulin Cache
id: tarpaulin_cache
uses: actions/cache@v2
with:
path: ~/.cargo/bin/cargo-tarpaulin
key: ${{ runner.os }}-cargo-tarpaulin

- uses: actions-rs/cargo@v1
if: steps.tarpaulin_cache.outputs.cache-hit != 'true'
with:
command: install
args: cargo-tarpaulin

- name: 'Run `cargo-tarpaulin`'
uses: actions-rs/cargo@v1
with:
command: tarpaulin
args: --workspace

- name: Upload to codecov.io
uses: codecov/codecov-action@v1
with:
file: ./target/tarpaulin/cobertura.xml

build_and_test_linux:
name: Build and Test (Linux)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: actions-rs/cargo@v1
with:
command: test
args: --release

build_and_test_windows:
name: Build and Test (Windows)
runs-on: windows-latest
timeout-minutes: 10
steps:
- name: Prepare symlink configuration
run: git config --global core.symlinks true

- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: actions-rs/cargo@v1
with:
command: test
args: --release
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

13 changes: 4 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ path = "src/lib.rs"
proc-macro = true

[dependencies]
proc-macro2 = "1.0.26"
proc-macro2 = "1.0.34"
proc_macro_roids = "0.7.0"
quote = "1.0.9"
syn = { version = "1.0.69", features = ["extra-traits", "visit"] }
quote = "1.0.10"
syn = { version = "1.0.82", features = ["extra-traits", "visit"] }

[dev-dependencies]
pretty_assertions = "0.6.1"

[badges]
appveyor = { repository = "azriel91/enum_variant_type" }
travis-ci = { repository = "azriel91/enum_variant_type" }
codecov = { repository = "azriel91/enum_variant_type" }
pretty_assertions = "1.0.0"
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Crates.io](https://img.shields.io/crates/v/enum_variant_type.svg)](https://crates.io/crates/enum_variant_type)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/azriel91/enum_variant_type?branch=master&svg=true)](https://ci.appveyor.com/project/azriel91/enum_variant_type/branch/master)
[![Build Status](https://travis-ci.org/azriel91/enum_variant_type.svg?branch=master)](https://travis-ci.org/azriel91/enum_variant_type)
[![Coverage Status](https://codecov.io/gh/azriel91/enum_variant_type/branch/master/graph/badge.svg)](https://codecov.io/gh/azriel91/enum_variant_type)
[![docs.rs](https://img.shields.io/docsrs/enum_variant_type)](https://docs.rs/enum_variant_type)
[![CI](https://github.com/azriel91/enum_variant_type/workflows/CI/badge.svg)](https://github.com/azriel91/enum_variant_type/actions/workflows/ci.yml)
[![Coverage Status](https://codecov.io/gh/azriel91/enum_variant_type/branch/main/graph/badge.svg)](https://codecov.io/gh/azriel91/enum_variant_type)

# Enum Variant Type

Expand Down Expand Up @@ -29,10 +29,7 @@ pub enum MyEnum {
Tuple(u32, u64),
/// Struct variant.
#[evt(derive(Debug))]
Struct {
field_0: u32,
field_1: u64,
},
Struct { field_0: u32, field_1: u64 },
/// Skipped variant.
#[evt(skip)]
Skipped,
Expand All @@ -42,7 +39,11 @@ pub enum MyEnum {
use core::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();
let named: Struct = Struct::try_from(MyEnum::Struct {
field_0: 12,
field_1: 34,
})
.unwrap();
let enum_unit = MyEnum::from(unit);
let enum_tuple = MyEnum::from(tuple);
Expand Down Expand Up @@ -144,6 +145,12 @@ impl TryFrom<MyEnum> for Struct {

</details>

#### Additional options specified by an `evt` attribute on enum:

* `#[evt(derive(Clone, Copy))]`: Derives `Clone`, `Copy` on **every** variant.
* `#[evt(module = "module1")]`: Generated structs are placed into `mod module1 { ... }`.
* `#[evt(implement_marker_traits(MarkerTrait1))]`: Generated structs all `impl MarkerTrait1`.

## License

Licensed under either of
Expand Down
4 changes: 3 additions & 1 deletion README.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[![Crates.io](https://img.shields.io/crates/v/enum_variant_type.svg)](https://crates.io/crates/enum_variant_type)
{{badges}}
[![docs.rs](https://img.shields.io/docsrs/enum_variant_type)](https://docs.rs/enum_variant_type)
[![CI](https://github.com/azriel91/enum_variant_type/workflows/CI/badge.svg)](https://github.com/azriel91/enum_variant_type/actions/workflows/ci.yml)
[![Coverage Status](https://codecov.io/gh/azriel91/enum_variant_type/branch/main/graph/badge.svg)](https://codecov.io/gh/azriel91/enum_variant_type)

# Enum Variant Type

Expand Down
121 changes: 0 additions & 121 deletions appveyor.yml

This file was deleted.

Loading

0 comments on commit 9f16b02

Please sign in to comment.