Skip to content

Commit

Permalink
[pdsl_core] Re-add BitBlock::new for test environments
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbepop committed Feb 25, 2019
1 parent 8cfa65a commit 4d927e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion core/src/storage/collections/bitvec/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with pDSL. If not, see <http://www.gnu.org/licenses/>.

use super::{BitPack, BitPackRepr};
use super::BitPack;
use parity_codec::{Encode, Decode};

/// A block of 1024 bits.
Expand Down Expand Up @@ -134,6 +134,25 @@ impl BitBlock {
#[cfg(test)]
mod tests {
use super::*;
use crate::storage::bitvec::pack::BitPackRepr;

impl BitBlock {
/// Creates a new bit block from the given underlying data.
///
/// # Note
///
/// Use this for testing purposes only.
pub(in self) fn new(raw_packs: [BitPackRepr; Self::PACKS as usize]) -> Self {
Self {
packs: unsafe {
core::intrinsics::transmute::<
[BitPackRepr; Self::PACKS as usize],
[BitPack; Self::PACKS as usize]
>(raw_packs)
}
}
}
}

/// Returns the maximum valid index of a bit block.
fn max_valid_index() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion core/src/storage/collections/bitvec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mod pack;
mod block;
mod vec;

pub(in self) use self::pack::{BitPack, BitPackRepr};
pub(in self) use self::pack::BitPack;
pub(in self) use self::block::BitBlock;
pub use self::vec::{
BitVec,
Expand Down

0 comments on commit 4d927e2

Please sign in to comment.