Skip to content

Commit

Permalink
Patch for 0.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
myrrlyn committed Jan 13, 2020
1 parent 2c3318e commit a90e931
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 23 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,25 @@ All notable changes will be documented in this file.

This document is written according to the [Keep a Changelog][kac] style.

## 0.17.1

### Added

This patch restores the `cursor` module and its types, as aliases to the `order`
module and their equivalents, with a deprecation warning. Removing these names
entirely, without a deprecation redirect, is technically permissible but morally
in error.

### Changed

In addition, the `Bits` trait has been renamed to `AsBits`, to better reflect
its behavior and reduce the chances of name collision, as it is a prelude
export.

### Removed

The `AsBits::as_{mut_,}bitslice` deprecation aliases have been removed.

## 0.17.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -6,7 +6,7 @@

[package]
name = "bitvec"
version = "0.17.0"
version = "0.17.1"
authors = [
"myrrlyn <self@myrrlyn.dev>",
]
Expand Down
24 changes: 5 additions & 19 deletions src/bits.rs
@@ -1,6 +1,6 @@
/*! Permit use of Rust native types as bit collections.
This module exposes a trait, `Bits`, which functions similarly to the `AsRef`
This module exposes a trait, `AsBits`, which functions similarly to the `AsRef`
and `AsMut` traits in the standard library. This trait allows an implementor to
express the means by which it can be interpreted as a collection of bits.
!*/
Expand All @@ -18,7 +18,7 @@ use crate::{
This trait can only be implemented by contiguous structures: individual
fundamentals, and sequences (arrays or slices) of them.
**/
pub trait Bits {
pub trait AsBits {
/// The underlying fundamental type of the implementor.
type Store: BitStore;

Expand Down Expand Up @@ -49,13 +49,6 @@ pub trait Bits {
fn bits<O>(&self) -> &BitSlice<O, Self::Store>
where O: BitOrder;

/// Synonym for [`bits`](#method.bits).
#[deprecated(since = "0.16.0", note = "Use `Bits::bits` instead")]
fn as_bitslice<O>(&self) -> &BitSlice<O, Self::Store>
where O: BitOrder {
Bits::bits(self)
}

/// Constructs a mutable `BitSlice` reference over data.
///
/// # Type Parameters
Expand Down Expand Up @@ -84,16 +77,9 @@ pub trait Bits {
/// ```
fn bits_mut<O>(&mut self) -> &mut BitSlice<O, Self::Store>
where O: BitOrder;

/// Synonym for [`bits_mut`](#method.bits_mut).
#[deprecated(since = "0.16.0", note = "Use `Bits::bits_mut` instead")]
fn as_mut_bitslice<O>(&mut self) -> &mut BitSlice<O, Self::Store>
where O: BitOrder {
Bits::bits_mut(self)
}
}

impl<T> Bits for T
impl<T> AsBits for T
where T: BitStore {
type Store = T;
fn bits<O>(&self) -> &BitSlice<O, T>
Expand All @@ -107,7 +93,7 @@ where T: BitStore {
}
}

impl<T> Bits for [T]
impl<T> AsBits for [T]
where T: BitStore {
type Store = T;
fn bits<O>(&self) -> &BitSlice<O, T>
Expand All @@ -123,7 +109,7 @@ where T: BitStore {

macro_rules! impl_bits_for {
($( $n:expr ),* ) => { $(
impl<T> Bits for [T; $n]
impl<T> AsBits for [T; $n]
where T: BitStore {
type Store = T;
fn bits<O>(&self) -> &BitSlice<O, T>
Expand Down
30 changes: 30 additions & 0 deletions src/lib.rs
Expand Up @@ -94,3 +94,33 @@ fn rca1(a: bool, b: bool, c: bool) -> (bool, bool) {
// Split them
(yz & 0b01 != 0, yz & 0b10 != 0)
}

/// Old name of the `order` module.
#[deprecated(
since = "0.17.0",
note = "This module was renamed to `order`, and will be removed in the next release."
)]
pub mod cursor {
/// Old name of the `Msb0` type.
#[deprecated(
since = "0.17.0",
note = "This type was renamed to `order::Msb0`, and will be removed in the next release."
)]
pub type BigEndian = crate::order::Msb0;

/// Old name of the `Lsb0` type.
#[deprecated(
since = "0.17.0",
note = "This type was renamed to `order::Lsb0`, and will be removed in the next release."
)]
pub type LittleEndian = crate::order::Lsb0;

/// Old name of the `BitOrder` trait.
#[deprecated(
since = "0.17.0",
note = "This trait was renaved to `order::BitOrder`, and will be removed in the next release."
)]
// Silence the lint, as this is a rename rather than a bare trait object.
#[allow(bare_trait_objects)]
pub type Cursor = crate::order::BitOrder;
}
5 changes: 4 additions & 1 deletion src/prelude.rs
Expand Up @@ -6,7 +6,7 @@ This collects the general public API into a single spot for inclusion, as

pub use crate::{
bits,
bits::Bits,
bits::AsBits,
fields::BitField,
order::{
BitOrder,
Expand All @@ -28,3 +28,6 @@ pub use crate::{
boxed::BitBox,
vec::BitVec,
};

#[allow(deprecated)]
pub use crate::cursor::*;
2 changes: 1 addition & 1 deletion src/slice/tests.rs
Expand Up @@ -4,7 +4,7 @@
use super::*;

use crate::{
bits::Bits,
bits::AsBits,
order::Msb0,
};

Expand Down
2 changes: 1 addition & 1 deletion src/slice/traits.rs
Expand Up @@ -433,7 +433,7 @@ where O: BitOrder, T: BitStore {}
#[cfg(all(test, feature = "alloc"))]
mod tests {
use crate::{
bits::Bits,
bits::AsBits,
order::Msb0,
};

Expand Down

0 comments on commit a90e931

Please sign in to comment.