mirror of
https://github.com/danog/strum.git
synced 2024-11-26 20:14:40 +01:00
Fixed some documentation bugs
This commit is contained in:
parent
033a376130
commit
1801a300d3
28
README.md
28
README.md
@ -27,6 +27,19 @@ extern crate strum;
|
||||
extern crate strum_macros;
|
||||
```
|
||||
|
||||
# Contributing
|
||||
|
||||
Thanks for your interest in contributing. The project is divided into 3 parts, the traits are in the
|
||||
`/strum` folder. The procedural macros are in the `/strum_macros` folder, and the integration tests are
|
||||
in `/strum_tests`. Tests are still a work in progress, but they should be added in the test project to
|
||||
verify that the macros are working correctly with the trait definitions.
|
||||
|
||||
# Debugging
|
||||
|
||||
To see the generated code, set the STRUM_DEBUG environment variable before compiling your code.
|
||||
`STRUM_DEBUG=1` will dump all of the generated code for every type. `STRUM_DEBUG=YourType` will
|
||||
only dump the code generated on a type named `YourType`.
|
||||
|
||||
# Strum Macros
|
||||
|
||||
Strum has implemented the following macros:
|
||||
@ -269,20 +282,7 @@ fn main() {
|
||||
Tokens::OpenParen,
|
||||
Tokens::CloseParen]);
|
||||
}
|
||||
```
|
||||
|
||||
# Contributing
|
||||
|
||||
Thanks for your interest in contributing. The project is divided into 3 parts, the traits are in the
|
||||
`/strum` folder. The procedural macros are in the `/strum_macros` folder, and the integration tests are
|
||||
in `/strum_tests`. Tests are still a work in progress, but they should be added in the test project to
|
||||
verify that the macros are working correctly with the trait definitions.
|
||||
|
||||
# Debugging
|
||||
|
||||
To see the generated code, set the DEBUG_STRUM environment variable before compiling your code.
|
||||
`DEBUG_STRUM=1` will dump all of the generated code for every type. `DEBUG_STRUM=YourType` will
|
||||
only dump the code generated on a type named `YourType`.
|
||||
``
|
||||
|
||||
# Name
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "strum"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = ["Peter Glotfelty <peglotfe@microsoft.com>"]
|
||||
license = "MIT"
|
||||
|
||||
@ -13,7 +13,7 @@ homepage = "https://github.com/Peternator7/strum"
|
||||
readme = "../README.md"
|
||||
|
||||
[dev-dependencies]
|
||||
strum_macros = "0.2.1"
|
||||
strum_macros = "0.2.2"
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "Peternator7/strum" }
|
@ -64,9 +64,9 @@
|
||||
//! /*
|
||||
//! //The generated code will look like:
|
||||
//! impl ::std::str::FromStr for Color {
|
||||
//! type Err = strum::ParseError;
|
||||
//! type Err = ::strum::ParseError;
|
||||
//!
|
||||
//! fn from_str(s: &str) -> Result<Color, Self::Error> {
|
||||
//! fn from_str(s: &str) -> ::std::result::Result<Color, Self::Error> {
|
||||
//! match s {
|
||||
//! "Red" => ::std::result::Result::Ok(Color::Red),
|
||||
//! "Green" => ::std::result::Result::Ok(Color::Green { range:Default::default() }),
|
||||
@ -282,16 +282,10 @@
|
||||
//!
|
||||
//! # Debugging
|
||||
//!
|
||||
//! To see the generated code, set the DEBUG_STRUM environment variable before compiling your code.
|
||||
//! `DEBUG_STRUM=1` will dump all of the generated code for every type. `DEBUG_STRUM=YourType` will
|
||||
//! To see the generated code, set the STRUM_DEBUG environment variable before compiling your code.
|
||||
//! `STRUM_DEBUG=1` will dump all of the generated code for every type. `STRUM_DEBUG=YourType` will
|
||||
//! only dump the code generated on a type named YourType.
|
||||
//!
|
||||
//! # Name
|
||||
//!
|
||||
//! 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.
|
||||
|
||||
/// The ParseError enum is a collection of all the possible reasons
|
||||
/// an enum can fail to parse from a string.
|
||||
@ -302,6 +296,8 @@ pub enum ParseError {
|
||||
|
||||
impl std::fmt::Display for ParseError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||
// We could use our macro here, but this way we don't take a dependency on the
|
||||
// macros crate.
|
||||
match self {
|
||||
&ParseError::VariantNotFound => write!(f, "Matching variant not found"),
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "strum_macros"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = ["Peter Glotfelty <peglotfe@microsoft.com>"]
|
||||
license = "MIT"
|
||||
|
||||
|
@ -74,3 +74,14 @@ enum Lifetime<'a> {
|
||||
fn lifetime_test() {
|
||||
assert_eq!(Lifetime::Life(""), Lifetime::from_str("Life").unwrap());
|
||||
}
|
||||
|
||||
#[derive(Debug,Eq,PartialEq,EnumString)]
|
||||
enum Generic<T: Default> {
|
||||
Gen(T),
|
||||
None,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generic_test() {
|
||||
assert_eq!(Generic::Gen(""), Generic::from_str("Gen").unwrap());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user