bitstructs 0.2.1

Defining type-safe bitfield structures that can be used in both `std` and `no_std` environments.
Documentation
# Bitstructs

`bitstructs`是一个可同时用于std和no_std 环境,定义类型安全的位域结构体的库。

## 功能特点

- 类型安全的位操作
- 使用简单和灵活度高
- 支持 no_std 和 std
- 使用proc-macro,无额外的运行代码

## 示例

下面是一个简单的使用`bitstructs`的例子。

```rust
use bitstructs::{bitstruct_cow};
bitstruct_cow! {
    #[derive(Clone, Debug, PartialEq)]
    pub struct Test {
        a: 1,
        b: 2,
        c: 2 =>
        pub enum C {
            C0 = 0,
            C1 = 1,
        },
    }
}
let mut value = Test::new();
assert_eq!(value.as_bytes(), vec![0b0000_0000]);
value.set_a(true);
unsafe { value.set_b(1) };
value.set_c(C::C1);
assert_eq!(value.as_bytes(), vec![0b0000_1011]);
```

默认情况下,采取的是LSB0和小端模式。如果要使用MSB0和大端模式,可以在`bitstruct_owned`宏中添加`#[bitstruct_repr(MSB0)]`数。

```rust
use bitstructs::{bitstruct_cow};
bitstruct_cow! {
    /// MSB0和大端模式
    #[derive(Clone, Debug, PartialEq)]
    #[bitstruct_repr(MSB0)]
    pub struct Test {
        a: 1,
        b: 2,
        c: 2 =>
        pub enum C {
            C0 = 0,
            C1 = 1,
        },
    }
}
let mut value = Test::new();
assert_eq!(value.to_bytes(), vec![0b0000_0000]);
value.set_a(true);
unsafe { value.set_b(1) };
value.set_c(C::C1);
assert_eq!(value.to_bytes(), vec![0b1010_1000]);
```

## 文档

更多信息,请查看e [documentation](https://docs.rs/bitstructs).

## 贡献

欢迎贡献!请在 [GitHub](https://github.com/small-white0-0/bitstructs) 上提交问题或拉取请求。