rust-bitcoin-unsafe-fast/src/util/mod.rs

42 lines
1.1 KiB
Rust
Raw Normal View History

2014-07-18 13:56:17 +00:00
// Rust Bitcoin Library
// Written in 2014 by
// Andrew Poelstra <apoelstra@wpsoftware.net>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
//
//! # Utility functions
//!
//! Functions needed by all parts of the Bitcoin library
pub mod error;
2014-07-18 13:56:17 +00:00
pub mod hash;
pub mod iter;
pub mod misc;
pub mod patricia_tree;
pub mod thinvec;
pub mod uint;
/// A trait which allows numbers to act as fixed-size bit arrays
pub trait BitArray {
/// Is bit set?
fn bit(&self, idx: uint) -> bool;
/// Returns an array which is just the bits from start to end
fn bit_slice(&self, start: uint, end: uint) -> Self;
/// Bitwise and with `n` ones
fn mask(&self, n: uint) -> Self;
/// Trailing zeros
fn trailing_zeros(&self) -> uint;
}