Skip to content

Commit

Permalink
docs: Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GrayJack committed Nov 18, 2024
1 parent 0f02ab7 commit 37faf19
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,21 @@ The macro will also implement some traits for bitwise operations and formatting.
- [X] Clone
- [X] Copy

Besides the `Debug`, `Clone` and `Copy` traits, all other derivable traits can be used together with the type.
Besides the `Debug`, `Clone` and `Copy` traits, all other standard derivable traits can be used together with the type.

The macro also generate iterator types to iterate over the set flags, and for convenience also implement the following traits:

- [X] core::iter::Extend
- [X] core::iter::FromIterator
- [X] core::iter::Iterator (for the type and reference)

There is a opt-in crate feature `serde` that generate a parsing error type and implements the traits:

- [X] core::str::FromStr
- [X] serde::Serialize
- [X] serde::Deserialize

**Note:** This crate does not import/re-export serde traits, your project MUST have `serde` as dependency.

## Example

Expand Down
13 changes: 12 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ use syn::{parse::Parse, punctuated::Punctuated, Error, Ident, ItemEnum, Result,
/// This macro generates some trait implementations: [`fmt::Debug`], [`ops:Not`], [`ops:BitAnd`],
/// [`ops:BitOr`], [`ops:BitXor`], [`ops:BitAndAssign`], [`ops:BitOrAssign`], [`ops:BitXorAssign`],
/// [`fmt::Binary`], [`fmt::LowerHex`], [`fmt::UpperHex`], [`fmt::Octal`], [`From`], [`Clone`],
/// [`Copy`]
/// [`Copy`], [`Extend`], [`FromIterator`], [`IntoIterator`]
///
/// If the macro receives `no_auto_debug`, the trait [`fmt::Debug`] will not be generated. Use this
/// flag when you want to implement [`fmt::Debug`] manually or use the standard derive.
///
/// ## Serde feature
///
/// If the crate is compiled with the `serde` feature, this crate will generate implementations for
/// the `serde::{Serialize, Deserialize}` traits, but it will not import/re-export these traits,
/// your project must have `serde` as dependency.
///
/// Having this feature enabled will also generate a type to represent the parsing error and helper
/// functions to do parsing the generated type from strings. And will generate the implementation
/// for the [`FromStr`] trait.
///
/// # Example
///
/// ```
Expand Down Expand Up @@ -81,6 +91,7 @@ use syn::{parse::Parse, punctuated::Punctuated, Error, Ident, ItemEnum, Result,
/// [`fmt::UpperHex`]: core::fmt::UpperHex
/// [`fmt::Octal`]: core::fmt::Octal
/// [`From`]: From
/// [`FromStr`]: core::str::FromStr
#[proc_macro_attribute]
pub fn bitflag(attr: TokenStream, item: TokenStream) -> TokenStream {
match bitflag_impl(attr, item) {
Expand Down

0 comments on commit 37faf19

Please sign in to comment.