#bit-manipulation #operations #integer #operation #library

sbitty

library defining bitwise operations on standard integers type

11 releases (3 stable)

1.1.1 Nov 21, 2020
1.0.1 Aug 23, 2019
0.5.5 Aug 22, 2019
0.1.1 Aug 22, 2019

#1665 in Algorithms

MIT license

18KB
363 lines

sbitty: when standard bits become easy Build Status Crate API

This crate aims to give simple interface to bit twiddling. There is lots of standard define behavior on bitwise operation like & | ^ ! but none for single bit operations on the standard int.

Some crates emulate bitfield but i found it restrictive since on all my project i usually use those operations on extra bit of a usable number.

Setup

In your Cargo.toml:

[dependencies]
sbitty = "^1.0.0"

In your source:

use sbitty::{GetBits,SetBits,IndexError};
use sbitty::*;
use sbitty::GetBits;

lib.rs:

Standard integers does not have any standard implementation of bitwise manipulation. This crate is made to fill this gap and hide ugly bitwise operation which are error prone behind some runtime safe functions.

It is made so you only have to call functions to use it properly. This crate use indexes as you would in vectors or Arrays. If any index error happened in your program you will get Option<T> or Result<_,_> returned to properly handle this in a production ready manner.

No runtime deps