1
0
mirror of https://github.com/danog/strum.git synced 2024-11-26 20:14:40 +01:00

Update README.md

Fixed the link on the readme and removed some of the lines that rustdoc parses differently than a standard markdown parser
This commit is contained in:
Peter Glotfelty 2017-02-12 12:52:51 -08:00 committed by GitHub
parent 04f0726668
commit 460700124a

View File

@ -2,7 +2,7 @@
[![Build Status](https://travis-ci.org/Peternator7/strum.svg?branch=master)](https://travis-ci.org/Peternator7/strum)
[![Latest Version](https://img.shields.io/crates/v/strum.svg)](https://crates.io/crates/strum)
[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/strum/badge.svg)
[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/strum)
Strum is a set of macros and traits for working with
enums and strings easier in Rust.
@ -25,7 +25,6 @@ And add these lines to the root of your project, either lib.rs or main.rs.
extern crate strum;
#[macro_use]
extern crate strum_macros;
# fn main() {}
```
# Strum Macros
@ -43,8 +42,8 @@ Strum has implemented the following macros:
Here is an example of the code generated by deriving `EnumString`.
```
# extern crate strum;
# #[macro_use] extern crate strum_macros;
extern crate strum;
#[macro_use] extern crate strum_macros;
#[derive(EnumString)]
enum Color {
Red,
@ -76,7 +75,6 @@ Strum has implemented the following macros:
}
}
*/
# fn main() {}
```
Note that the implementation of `FromStr` only matches on the name of the variant.
@ -91,9 +89,6 @@ Strum has implemented the following macros:
create [unbounded lifetimes] (https://doc.rust-lang.org/nightly/nomicon/unbounded-lifetimes.html).
```rust
# extern crate strum;
# #[macro_use] extern crate strum_macros;
# use std::fmt::Debug;
// You need to bring the type into scope to use it!!!
use strum::IntoEnumIterator;
@ -126,8 +121,6 @@ Strum has implemented the following macros:
The generated code will look something like:
```rust
# extern crate strum;
# #[macro_use] extern crate strum_macros;
// You need to bring the type into scope to use it!!!
use strum::EnumMessage;
@ -178,7 +171,6 @@ Strum has implemented the following macros:
}
}
*/
# fn main() {}
```
# Additional Attributes
@ -220,8 +212,8 @@ Using `EnumMessage` for quickly implementing `Error`
extern crate strum;
#[macro_use]
extern crate strum_macros;
# use std::error::Error;
# use std::fmt::*;
use std::error::Error;
use std::fmt::*;
use strum::EnumMessage;
#[derive(Debug, EnumMessage)]
@ -245,7 +237,6 @@ impl Error for ServerError {
self.get_detailed_message().unwrap()
}
}
# fn main() {}
```
Using `EnumString` to tokenize a series of inputs:
@ -285,4 +276,4 @@ fn main() {
Strum is short for STRing enUM because it's a library for augmenting enums with additional
information through strings.
Strumming is also a very whimsical motion, much like writing Rust code.
Strumming is also a very whimsical motion, much like writing Rust code.