Skip to content

Commit

Permalink
Staging v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
haxelion committed Jul 7, 2024
1 parent 9c28d5d commit f3c4cb5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "bva"
version = "0.2.0"
version = "0.3.0"
authors = ["Charles Hubain <[email protected]>"]
edition = "2021"
rust-version = "1.61"
description = "bva is a crate for manipulating bit vectors and doing arithmetics on arbitrarily sized bit vectors."
description = "bva is a rust crate for manipulating and doing arithmetics on bit vectors of fixed but arbitrary size."
documentation = "https://docs.rs/bva"
readme = "README.md"
homepage = "https://github.com/haxelion/bva/"
Expand Down
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
![Minimum Rust 1.61](https://img.shields.io/badge/Rust-1.61+-red.svg)
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

`bva` is a rust crate for manipulating bit vectors and doing arithmetics on arbitrarily sized bit
vectors.
`bva` is a rust crate for manipulating and doing arithmetics on bit vectors of
fixed but arbitrary size. They are meant to behave like CPU hardware registers with wrap-around on overflow.

This crate emphasizes optimizing storage by providing alternative storage options.
The module `fixed` contains implementations using unsigned integers as storage and thus
has a fixed capacity. The module `dynamic` contains an implementation using dynamically
allocated array of integers as storage and therefore has a dynamic capacity. The module
`auto` contains an implementation capable of switching at runtime between a fixed or
dynamic capacity implementation to try to minimize dynamic memory allocations.
All of those implementations implement the `BitVector` trait and can be freely mixed together
and converted into each other.
The module `fixed` contains implementations using arrays of unsigned integers as storage and thus have a fixed capacity. The module `dynamic` contains an implementation using a dynamically allocated array of integers as storage and therefore has a dynamic capacity. The module `auto` contains an implementation capable of switching at runtime between a fixed or dynamic capacity implementation to try to minimize dynamic memory allocations. All of those implementations implement the `BitVector` trait and can be freely mixed together and used interchangeably via generic traits.

## Changelog

* 2024/07/07 - 0.3.0
* Multiplication, division and modulo operations
* Various helper functions
* Much more rigorous testing reaching high code coverage.
* 2023/07/04 - 0.2.0
* Major rewrite using const generics
* Iterator support
Expand All @@ -30,12 +28,12 @@ and converted into each other.
* Basic arithmetic operations between the different implementations.
* Reading and writing bit vector in various format.

## TODO
## Roadmap

* More "advanced" arithmetics: multiplication, division, remainder.
* Fix Display for bit vector longer than 128 bits.
* Aiming for 100% code coverage.
* Signed operation support.
* Borrowing of bits and bit slice inside a bit vector.
* Really advanced arithmetics: gcd, modular exponentiation, ...
* Numerical algorithms such as gcd, modular exponentiation, ...
* no-std support

## Why
Expand Down
25 changes: 13 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
//! Crate for manipulating bit vectors and doing arithmetic on arbitrarily sized bit vectors.
//! This crate is for manipulating and doing arithmetics on bit vectors of fixed but arbitrary size.
//! They are meant to behave like CPU hardware registers with wrap-around on overflow.
//!
//! This crate emphasizes optimizing storage by providing alternative storage options.
//! The module [`fixed`] contains implementations using unsigned integers as storage and thus
//! has a fixed capacity. The module [`dynamic`] contains an implementation using dynamically
//! allocated array of integers as storage and therefore has a dynamic capacity. The module
//! [`auto`] contains an implementation capable of switching at runtime between a fixed or
//! dynamic capacity implementation to try to minimize dynamic memory allocations.
//! All of those implementations implement the [`BitVector`] trait and can be freely mixed together
//! and converted into each other.
//! The module `fixed` contains implementations using arrays of unsigned integers as storage and
//! thus have a fixed capacity. The module `dynamic` contains an implementation using a dynamically
//! allocated array of integers as storage and therefore has a dynamic capacity. The module `auto`
//! contains an implementation capable of switching at runtime between a fixed or dynamic capacity
//! implementation to try to minimize dynamic memory allocations. All of those implementations
//! implement the `BitVector` trait and can be freely mixed together and used interchangeably via
//! generic traits.
//!
//! The different bit vector types represent a vector of bits where the bit at index 0 is the least
//! significant bit and the bit at index `.len() - 1` is the most significant bit. There is no
//! notion of endianness for the bit vector themselves, endianness is only involved when reading or
//! writing a bit vector to or from memory or storage.
//!
//! Arithmetic operation can be applied to bit vectors of different length. The result will always
//! have the length of the longest operand and the smallest operand will be zero extended for the
//! operation. This should match the most intuitive behavior in most cases except when manipulating
//! bit vector supposed to have a sign bit.
//! Arithmetic operation can be applied to bit vectors of different types and different lengths.
//! The result will always have the type and the length of the left hand side operand and the right
//! hand side operand will be zero extended if needed. Operations will wrap-around in the case of
//! overflows. This should match the behavior of unsigned integer arithmetics on CPU registers.

#![allow(
clippy::suspicious_arithmetic_impl,
Expand Down

0 comments on commit f3c4cb5

Please sign in to comment.