Sign In

bitvec

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitvec - cargo Package Compare versions

Package version was removed
This package version has been unpublished, mostly likely due to security reasons
Comparing version
0.13.0
to
0.14.0
+30
c/bitvec/rust_types.h
#ifndef BITVEC_AUTOGEN_FFI_H
#define BITVEC_AUTOGEN_FFI_H
/* Prevent a C++ compiler from reading this file */
#ifndef __cplusplus
/**
* @file bitvec/rust_types.h
* @version 0.13.0
*
* @brief Bindings to Rust native types.
*
* This file is automatically generated by the Rust crate, and contains
* definitions of Rust native types that cross the FFI boundary.
*/
#include <stdint.h>
/** @brief `Option::<bool>::Some(false)` */
uint8_t OptionBool_False = 0;
/** @brief `Option::<bool>::Some(true)` */
uint8_t OptionBool_True = 1;
/** @brief `Option::<bool>::None` */
uint8_t OptionBool_None = 2;
#endif /* __cplusplus */
#endif /* BITVEC_AUTOGEN_FFI_H */
#ifndef BITVEC_AUTOGEN_FFI_HPP
#define BITVEC_AUTOGEN_FFI_HPP
/**
* @file bitvec/rust_types.hpp
* @version 0.13.0
*
* @brief Bindings to Rust native types.
*
* This file is automatically generated by the Rust crate, and contains
* definitions of Rust native types that cross the FFI boundary.
*/
#include <cstdint>
/**
* @enum OptionBool
*
* @brief Bindings to the Rust `Option<bool>` type and variants.
*/
enum
#if __cplusplus > 201101L
class
#endif // __cplusplus > 201101L
OptionBool
#if __cplusplus > 201101L
: std::uint8_t
#endif // __cplusplus > 201101L
{
/// @brief `Option::<bool>::Some(false)`
False = 0,
/// @brief `Option::<bool>::Some(true)`
True = 1,
/// @brief `Option::<bool>::None`
None = 2,
};
#endif // BITVEC_AUTOGEN_FFI_HPP
/*! Reserving space when a BitVec is filled to a boundary induces false panic.
This is due to a faulty validity check (`BitIdx::span` calls `BitIdx::is_valid`)
called during `BitVec::reserve` using the *tail* of the vector, which at the
boundary, is a valid tail but not a valid head.
This is a regression.
!*/
#![cfg(any(feature = "alloc", feature = "std"))]
use bitvec::prelude::*;
#[test]
fn issue_15() {
let mut bv = bitvec![0; 8];
bv.reserve(16);
}
+1
-1

@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

name = "bitvec"
version = "0.13.0"
version = "0.14.0"
authors = ["myrrlyn <self@myrrlyn.dev>"]

@@ -19,0 +19,0 @@ description = "A crate for manipulating memory, bit by bit"

@@ -7,2 +7,16 @@ # Changelog

## 0.14.0
### Added
- `add_assign_reverse` on `BitSlice` and `BitVec`, and `add_reverse` on
`BitBox` and `BitVec`.
These methods perform left-to-right addition, propagating the carry from the
0th bit in the sequence to the nth. On `BitSlice`, `add_assign_reverse`
returns the carry-out bit. On `BitVec`, `add_assign_reverse` and `add_reverse`
push the carry-out to the right end of the vector.
This feature was requested in [Issue #16], by GitHub user [@GeorgeGkas].
## 0.13.0

@@ -82,2 +96,8 @@

## 0.11.3
[Issue #15]: Incorrect validity check in `BitIdx::span`; excluded tail indices
which were used in `BitVec::push`, inducing false `panic!` events. Thanks to
GitHub user [@schomatis] for the report.
## 0.11.2

@@ -408,2 +428,3 @@

[@GeorgeGkas]: https://github.com/GeorgeGkas
[@geq1t]: https://github.com/geq1t

@@ -413,2 +434,3 @@ [@koushiro]: https://github.com/koushiro

[@ratorx]: https://github.com/ratorx
[@schomatis]: https://github.com/schomatis
[@torce]: https://github.com/torce

@@ -420,3 +442,5 @@ [Issue #7]: https://github.com/myrrlyn/bitvec/issues/7

[Issue #12]: https://github.com/myrrlyn/bitvec/issues/12
[Issue #15]: https://github.com/myrrlyn/bitvec/issues/15
[Issue #16]: https://github.com/myrrlyn/bitvec/issues/16
[`Sync`]: https://doc.rust-lang.org/stable/core/marker/trait.Sync.html
[kac]: https://keepachangelog.com/en/1.0.0/

@@ -392,2 +392,20 @@ /*! `BitBox` structure

/// Performs “reverse” addition (left to right instead of right to left).
///
/// This delegates to `BitSlice::add_assign_reverse`.
///
/// # Parameters
///
/// - `self`
/// - `addend: impl IntoIterator<Item=bool>`: A bitstream to add to `self`.
///
/// # Returns
///
/// The sum of `self` and `addend`.
pub fn add_reverse<I>(mut self, addend: I) -> Self
where I: IntoIterator<Item=bool> {
self.add_assign_reverse(addend);
self
}
/// Changes the cursor on a box handle, without changing the data it

@@ -394,0 +412,0 @@ /// governs.

@@ -91,1 +91,46 @@ /*! `bitvec` – `[bool]` in overdrive.

}
/** Perform single-bit ripple-carry addition.
This function performs carry-aware binary addition on single bits of each
addend. It is used in multiple places throughout the library, and so is pulled
here for deduplication.
# Parameters
- `a: bool`: One bit of addend.
- `b: bool`: One bit of addend.
- `c: bool`: The carry-bit input.
# Returns
- `.0: bool`: The sum of `a + b + c`.
- `.1: bool`: The carry-out of `a + b + c`.
**/
#[inline]
fn rca1(a: bool, b: bool, c: bool) -> (bool, bool) {
/// Ripple-carry addition is a reduction operation from three bits of input
/// (a, b, carry-in) to two outputs (sum, carry-out). This table contains
/// the map of all possible inputs to their output.
// Note: I checked in Godbolt, and the jump table lookup comes out to ~ten
// simple instructions with the table baked in as immediate values. The
// more semantically clear match statement does not optimize nearly as
// well.
const RCA: [u8; 8] = [
// a + b + c => (y, z)
0, // 0 + 0 + 0 => (0, 0)
2, // 0 + 1 + 0 => (1, 0)
2, // 1 + 0 + 0 => (1, 0)
1, // 1 + 1 + 0 => (0, 1)
2, // 0 + 0 + 1 => (1, 0)
1, // 0 + 1 + 1 => (0, 1)
1, // 1 + 0 + 1 => (0, 1)
3, // 1 + 1 + 1 => (1, 1)
];
// Compute the lookup index from carry-in, left, and right
let jmp = ((c as u8) << 2) | ((a as u8) << 1) | (b as u8);
// Look up the output bits
let yz = RCA[jmp as usize];
// Split them
(yz & 2 != 0, yz & 1 != 0)
}
{
"git": {
"sha1": "386d6547d4ef508fc7357b62a61488c44bcbacc9"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display