Light Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 29, 2023. It is now read-only.

griffi-gh/const-twiddle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

11 Commits

Repository files navigation

const-twiddle

Bitwise utility functions

const-twiddle is a set of bitwise utility functions designed to be similar to twiddle. It is also compatible with const and supports #![no_std] out of the box.

Usage

Add const-twiddle to your Cargo.toml file:

[dependencies]
const-twiddle = "0.1"

Usage outside of const:

use const_twiddle::Twiddle;

fn test() {
let mut x = 5;
x.set_bit(0, false);
assert_eq!(x, 4);
assert_eq!(x.with_bit(0, true), 5);
assert_eq!(x.bit(0), false);
}

Usage inside const contexts:

use const_twiddle::ConstU32;

const fn test() {
// Traits are not supported in const yet
let x = ConstU32(5).with_bit(0, false).0; //x = 4
}

License

const-twiddle is licensed under the MIT License. See the LICENSE file for more details.

About

Bitwise utility functions

Topics

Resources

Readme

License

MIT license

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages