Deduplicate bitflags/bitarray_to_byte

master
Simon Bruder 2020-07-08 23:55:04 +02:00
parent f66508eef7
commit 95f4a4c60c
No known key found for this signature in database
GPG Key ID: 6F03E0000CC5B62F
2 changed files with 2 additions and 13 deletions

View File

@ -14,15 +14,6 @@ pub type SampleIndex = u16;
pub type Time = u32;
// Helper functions
fn bitflags(flags: [bool; 8]) -> u8 {
let mut value = 0u8;
for (i, flag) in flags.iter().enumerate() {
value += ((0b1 as u8) << i) * (*flag as u8) as u8;
}
value
}
fn assemble_hit_object_type(hit_object_type: u8, new_combo: bool, skip_combo_colours: U3) -> u8 {
let hit_object_type = 1u8 << hit_object_type;
let new_combo = if new_combo { 0b0000_0010_u8 } else { 0u8 };
@ -255,7 +246,7 @@ impl fmt::Display for TimingPointEffects {
write!(
f,
"{}",
bitflags([
utils::bitarray_to_byte([
self.kiai_time,
false,
false,
@ -360,7 +351,7 @@ impl fmt::Display for HitSound {
write!(
f,
"{}",
bitflags([
utils::bitarray_to_byte([
self.normal,
self.whistle,
self.finish,

View File

@ -12,8 +12,6 @@ pub fn byte_to_bitarray(byte: u8) -> [bool; 8] {
bitarray
}
#[allow(dead_code)]
/// Used to test `byte_to_bitarray`
pub fn bitarray_to_byte(bitarray: [bool; 8]) -> u8 {
bitarray
.iter()