From 0ad0d503a2eb69ad09c883fcb854b978d5419e87 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Wed, 8 Jul 2020 23:55:52 +0200 Subject: [PATCH] Remove U3 type for osu beatmap It did not do any checking and looked weird. What *is* the right way to ensure the value only has 3 bytes while still allowing the user to pass a normal primitive or newtype wrapper around a primitive (and not e.g. a [bool; 3])? --- src/osu/beatmap.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/osu/beatmap.rs b/src/osu/beatmap.rs index c4f0517..e0b89fb 100644 --- a/src/osu/beatmap.rs +++ b/src/osu/beatmap.rs @@ -14,7 +14,7 @@ pub type SampleIndex = u16; pub type Time = u32; -fn assemble_hit_object_type(hit_object_type: u8, new_combo: bool, skip_combo_colours: U3) -> u8 { +fn assemble_hit_object_type(hit_object_type: u8, new_combo: bool, skip_combo_colours: u8) -> u8 { let hit_object_type = 1u8 << hit_object_type; let new_combo = if new_combo { 0b0000_0010_u8 } else { 0u8 }; let skip_combo_colours = (skip_combo_colours & 0b_0000_0111u8) << 1; @@ -384,9 +384,6 @@ impl fmt::Display for HitSample { } } -// Three bit integer -pub type U3 = u8; - #[derive(Clone)] pub enum HitObject { HitCircle { @@ -395,7 +392,7 @@ pub enum HitObject { time: Time, hit_sound: HitSound, new_combo: bool, - skip_combo_colours: U3, + skip_combo_colours: u8, hit_sample: HitSample, }, Slider { @@ -404,7 +401,7 @@ pub enum HitObject { time: Time, hit_sound: HitSound, new_combo: bool, - skip_combo_colours: U3, + skip_combo_colours: u8, curve_type: char, curve_points: Vec<(DecimalOsuPixel, DecimalOsuPixel)>, slides: u8, @@ -417,7 +414,7 @@ pub enum HitObject { time: Time, hit_sound: HitSound, new_combo: bool, - skip_combo_colours: U3, + skip_combo_colours: u8, end_time: Time, hit_sample: HitSample, }, @@ -427,7 +424,7 @@ pub enum HitObject { time: Time, hit_sound: HitSound, new_combo: bool, - skip_combo_colours: U3, + skip_combo_colours: u8, end_time: Time, hit_sample: HitSample, },