1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Bit related functionality intended for use with Crispii
//!
//! Provides extension methods to Rust's native unsigned int types for bit-level manipulations.
//!
//! The recommended approach for imports is to use the associated helper crate for the particular int variant you're using.
//!
//! For example, if you're using u8 values:
//! ```
//! use crispii_bits::u8::*;
//!
//! fn main() {
//! let mut register_a: u8 = 0b0000_0000;
//!
//! register_a = register_a.flip_bit(PosU8::B2); // 0b0000_0100
//!
//! register_a = register_a.set_bit(PosU8::B7, Bin::B1); // 0b1000_0100
//!
//! let (result, carried_bits) = register_a.add_with_carry(0b0000_0100);
//!
//! if carried_bits.contains(&PosU8::B2) {
//! println!("Addition operation resulted in a carry on bit 2");
//! }
//! }
//! ```
pub use Bin;
pub use PosU8;
pub use PosU16;
pub use PosU32;
pub use PosU64;
pub use PosU128;
pub use SetU8;
pub use SetU16;
pub use SetU32;
pub use SetU64;
pub use SetU128;
pub use FlipU8;
pub use FlipU16;
pub use FlipU32;
pub use FlipU64;
pub use FlipU128;
pub use AddWithCarryU8;
pub use AddWithCarryU16;
pub use AddWithCarryU32;
pub use AddWithCarryU64;
pub use AddWithCarryU128;