cargo fmt+一些unsafe

This commit is contained in:
shenjack 2024-05-03 22:45:58 +08:00
parent de70dfa8d9
commit 64d17813c2
Signed by: shenjack
GPG Key ID: 7B1134A979775551
3 changed files with 22 additions and 16 deletions

View File

@ -424,7 +424,6 @@ impl Namer {
) as u32
+ 36;
}
}
#[inline(always)]
@ -533,9 +532,17 @@ impl Namer {
#[inline(always)]
pub fn get_property(&self) -> f32 {
let sum1 = self.name_prop[1..=7].iter().sum::<u32>();
let sum2 = self.name_prop[0];
sum1 as f32 + (sum2 as f32 / 3_f32)
unsafe {
// (self.name_prop.get_unchecked(1)
// + self.name_prop.get_unchecked(2)
// + self.name_prop.get_unchecked(3)
// + self.name_prop.get_unchecked(4)
// + self.name_prop.get_unchecked(5)
// + self.name_prop.get_unchecked(6)
// + self.name_prop.get_unchecked(7)) as f32
// + (*self.name_prop.get_unchecked(0) as f32 / 3_f32)
self.name_prop.get_unchecked(1..=7).iter().sum::<u32>() as f32 + (*self.name_prop.get_unchecked(0) as f32 / 3_f32)
}
}
pub fn get_净化(&self) -> u8 {
@ -745,6 +752,7 @@ mod test {
let prop_vec: Vec<u32> = vec![344, 57, 53, 66, 72, 70, 71, 61];
assert_eq!(namer.name_prop.to_vec(), prop_vec);
assert_eq!(namer.get_property(), 564.6667_f32);
}
#[test]
@ -753,6 +761,7 @@ mod test {
let prop_vec: Vec<u32> = vec![240, 89, 69, 82, 65, 75, 49, 49];
assert_eq!(name.name_prop.to_vec(), prop_vec);
assert_eq!(name.get_property(), 558_f32);
}
#[test]
@ -774,6 +783,5 @@ mod test {
assert_eq!(namer.val.to_vec(), none_update_name.val.to_vec());
assert_eq!(namer.skl_id.to_vec(), none_update_name.skl_id.to_vec());
assert_eq!(namer.skl_freq.to_vec(), none_update_name.skl_freq.to_vec());
}
}

View File

@ -1,4 +1,3 @@
pub mod runners {
use crate::name::Player;
@ -10,6 +9,6 @@ pub mod runners {
/// 应该是一个 Rc4 实例类似物
seed: u32,
/// 所有玩家 (包括 boss)
players: Vec<PlayerGroup>
players: Vec<PlayerGroup>,
}
}

View File

@ -1,7 +1,6 @@
/// 万里长征, 始于足下
mod name;
mod engine;
/// 万里长征, 始于足下
mod name;
mod rc4;
fn main() {