Skip to content

Commit 6492b2f

Browse files
committed
update metadata
1 parent 3763f16 commit 6492b2f

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
[package]
22
name = "proxy-enum"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
authors = ["Moritz Bischof <[email protected]>"]
55
edition = "2018"
66
description = "Emulate dynamic dispatch and sealed classes using a proxy enum, which defers all method calls to its variants."
77
license = "MIT"
8+
readme = "README.md"
9+
repository = "https://github.com/NyxCode/proxy-enum"
10+
keywords = ["proxy", "enum", "sealed", "variant"]
811

912
[lib]
1013
proc-macro = true

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# proxy-enum
2+
![Crates.io](https://img.shields.io/crates/d/proxy-enum?style=flat-square)
3+
![](https://docs.rs/mio/badge.svg)
24

35
Emulate dynamic dispatch and ["sealed classes"](https://kotlinlang.org/docs/reference/sealed-classes.html) using a proxy enum, which defers all method calls to its variants.
46

@@ -7,7 +9,7 @@ In rust, dynamic dispatch is done using trait objects (`dyn Trait`).
79
They enable us to have runtime polymorphism, a way of expressing that a type implements a
810
certain trait while ignoring its concrete implementation.
911

10-
```
12+
```rust
1113
let animal: &dyn Animal = random_animal();
1214
animal.feed(); // may print "mew", "growl" or "squeak"
1315
```
@@ -18,7 +20,7 @@ getting a concrete implementation back from a trait object (downcasting) is pain
1820

1921
If you know there are only a finite number of implentations to work with, an `enum` might be
2022
better at expressing such a relationship:
21-
```
23+
```rust
2224
enum Animal {
2325
Cat(Cat),
2426
Lion(Lion),
@@ -38,7 +40,7 @@ Rust, however, does *not*.
3840
`proxy-enum` simplifies working with such types using procedural macros.
3941

4042
## Usage
41-
```
43+
```rust
4244
#[proxy_enum::proxy(Animal)]
4345
mod proxy {
4446
enum Animal {
@@ -54,7 +56,7 @@ mod proxy {
5456
}
5557
```
5658
This will expand to:
57-
```
59+
```rust
5860
mod proxy {
5961
enum Animal {
6062
Cat(Cat),
@@ -75,7 +77,7 @@ mod proxy {
7577
```
7678
This, however, will only compile if `Cat`, `Lion` and `Mouse` all have a method called `feed`.
7779
Since rust has traits to express common functionality, trait implentations can be generated too:
78-
```
80+
```rust
7981
#[proxy_enum::proxy(Animal)]
8082
mod proxy {
8183
enum Animal {
@@ -95,7 +97,7 @@ mod proxy {
9597
Since the macro has to know which methods the trait contains, it has to be defined within the
9698
module. However, implementations for external traits can be generated too:
9799

98-
```
100+
```rust
99101
#[proxy_enum::proxy(Animal)]
100102
mod proxy {
101103
enum Animal {

0 commit comments

Comments
 (0)