From 25d863242e2da958976b86f6a4fec1af21715f0c Mon Sep 17 00:00:00 2001 From: Cameron Pickett Date: Wed, 22 May 2024 12:20:28 -0700 Subject: [PATCH] Migrate off of bitvec-old Summary: Remove an existing instance of duplicate crate imports Reviewed By: jasonwhite Differential Revision: D57676132 fbshipit-source-id: 4a3861c3b79f19c77bc3b4c0f43087a9e58970c2 --- detcore-model/Cargo.toml | 2 +- detcore-model/src/pedigree.rs | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/detcore-model/Cargo.toml b/detcore-model/Cargo.toml index 0e9b7b0..2078c21 100644 --- a/detcore-model/Cargo.toml +++ b/detcore-model/Cargo.toml @@ -9,7 +9,7 @@ license = "BSD-3-Clause" [dependencies] anyhow = "1.0.75" -bitvec = { version = "0.17", features = ["serde"] } +bitvec = { version = "1.0", features = ["serde"] } bytesize = "1.1" chrono = { version = "0.4", features = ["clock", "serde", "std"], default-features = false } clap = { version = "3.2.25", features = ["derive", "env", "regex", "unicode", "wrap_help"] } diff --git a/detcore-model/src/pedigree.rs b/detcore-model/src/pedigree.rs index 42e42dd..56bcb0d 100644 --- a/detcore-model/src/pedigree.rs +++ b/detcore-model/src/pedigree.rs @@ -12,9 +12,7 @@ use std::fmt; use std::io; use std::mem; -use bitvec::bitvec; -use bitvec::order::Msb0; -use bitvec::vec::BitVec; +use bitvec::prelude::*; use libc::pid_t; use nix::unistd::Pid; use serde::Deserialize; @@ -118,7 +116,7 @@ impl TryFrom<&Pedigree> for i32 { // Trim off any trailing P's from pedigree, i.e. viewing it as // a sequence of 'P' (parent) and 'C' (child) directions. let mut sequence = pedigree.raw(); - while sequence.len() > 1 && sequence.last() == Some(&false) { + while sequence.len() > 1 && sequence.last().as_deref() == Some(&false) { sequence.pop(); } @@ -142,7 +140,7 @@ impl TryFrom<&Pedigree> for i32 { tree.append(&mut lower_tree); // Construct a BitVec which will be interpreted as a pid_t - let mut vpid_bits: BitVec = + let mut vpid_bits: BitVec = BitVec::with_capacity(mem::size_of::() * 8); // pid_t is signed, so MSB must always be zero or it will be interpreted as error @@ -152,22 +150,22 @@ impl TryFrom<&Pedigree> for i32 { // Pack the rest of the bits, using asserts to make sure the bitfield sizing // is correct. Any errors here are fatal bugs, so assert seems acceptable. - let mut tree_bits: BitVec = BitVec::repeat(false, TREE_BITS - tree.len()); + let mut tree_bits: BitVec = BitVec::repeat(false, TREE_BITS - tree.len()); tree_bits.append(&mut tree); debug_assert!(tree_bits.len() == TREE_BITS); vpid_bits.append(&mut tree_bits); - let mut run_index_bits = BitVec::::from_element(index as u32); + let mut run_index_bits = BitVec::::from_element(index as u32); run_index_bits = run_index_bits.split_off(run_index_bits.len() - RUN_INDEX_BITS); debug_assert!(run_index_bits.len() == RUN_INDEX_BITS); vpid_bits.append(&mut run_index_bits); - let mut run_type_bits: BitVec = BitVec::new(); + let mut run_type_bits: BitVec = BitVec::new(); run_type_bits.push(run[0]); debug_assert!(run_type_bits.len() == RUN_TYPE_BITS); vpid_bits.append(&mut run_type_bits); - let mut run_length_bits = BitVec::::from_element(len as u32); + let mut run_length_bits = BitVec::::from_element(len as u32); run_length_bits = run_length_bits.split_off(run_length_bits.len() - RUN_LENGTH_BITS); debug_assert!(run_length_bits.len() == RUN_LENGTH_BITS); vpid_bits.append(&mut run_length_bits);