Skip to content

Commit

Permalink
docs fixy-wixy
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Jul 22, 2023
1 parent 8ef82d3 commit 337ddff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bitfield/src/bitfield.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
///
/// Bitfields may also contain typed values, as long as those values implement
/// the [`FromBits`] trait. [`FromBits`] may be manually implemented, or
/// generated automatically for `enum` types using the [`enum_from_bits!] macro:
/// generated automatically for `enum` types using the [`enum_from_bits!`] macro:
///
/// ```
/// use mycelium_bitfield::{bitfield, enum_from_bits, FromBits};
Expand Down Expand Up @@ -141,9 +141,12 @@
/// }
/// }
///
/// Alternatively, the `enum_from_bits!` macro can be used to
/// automatically generate a `FromBits` implementation for an
/// enum type:
/// // Alternatively, the `enum_from_bits!` macro can be used to
/// // automatically generate a `FromBits` implementation for an
/// // enum type.
/// //
/// // The macro will generate very similar code to the example
/// // manual implementation above.
/// enum_from_bits! {
/// #[derive(Debug, Eq, PartialEq)]
/// pub enum MyGeneratedEnum<u8> {
Expand Down
10 changes: 10 additions & 0 deletions bitfield/src/from_bits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
use core::{convert::Infallible, fmt};

/// Trait implemented by values which can be converted to and from raw bits.
///
/// This trait is [implemented by default] for all signed and unsigned integer
/// types, as well as for `bool`s. It can be implemented manually for any
/// user-defined type which has a well-defined bit-pattern representation. For
/// `enum` types with unsigned integer `repr`s, it may also be implemented
/// automatically using the [`enum_from_bits!`] macro.
///
/// [implemented by default]: #foreign-impls
/// [`enum_from_bits!`]: crate::enum_from_bits!
pub trait FromBits<B>: Sized {
/// The error type returned by [`Self::try_from_bits`] when an invalid bit
/// pattern is encountered.
Expand Down Expand Up @@ -99,6 +108,7 @@ pub trait FromBits<B>: Sized {
/// Wont = 0b10,
/// Work = 0b11,
/// }
/// }
/// ```
///
/// [^1]: **Why Not `#[derive(FromBits)]`?** Some readers may be curious about why
Expand Down

0 comments on commit 337ddff

Please sign in to comment.