#no-std

no-std bit_field

Simple bit field trait providing get_bit, get_bits, set_bit, and set_bits methods for Rust’s integral types

12 releases (breaking)

Uses old Rust 2015

0.10.1 Aug 23, 2020
0.10.0 May 3, 2019
0.9.1 May 3, 2019
0.9.0 Nov 15, 2017
0.4.0 Jul 12, 2016

#125 in Rust patterns

Download history 7627/week @ 2021-02-26 7295/week @ 2021-03-05 7998/week @ 2021-03-12 8941/week @ 2021-03-19 8077/week @ 2021-03-26 7147/week @ 2021-04-02 5560/week @ 2021-04-09 4562/week @ 2021-04-16 8235/week @ 2021-04-23 10789/week @ 2021-04-30 10410/week @ 2021-05-07 13656/week @ 2021-05-14 15276/week @ 2021-05-21 14913/week @ 2021-05-28 9174/week @ 2021-06-04 8629/week @ 2021-06-11

34,619 downloads per month
Used in 149 crates (55 directly)

Apache-2.0/MIT

28KB
524 lines

bit_field

A simple crate which provides the BitField trait, which provides methods for operating on individual bits and ranges of bits on Rust's integral types.

Documentation

Documentation is available on docs.rs

Usage

[dependencies]
bit_field = "0.9.0"

Example

extern crate bit_field;
use bit_field::BitField;

let mut x: u8 = 0;

x.set_bit(7, true);
assert_eq!(x, 0b1000_0000);

x.set_bits(0..4, 0b1001);
assert_eq!(x, 0b1000_1001);

License

This crate is dual-licensed under MIT or the Apache License (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details.


lib.rs:

Provides the abstraction of a bit field, which allows for bit-level update and retrieval operations.

No runtime deps