fix vec trail

This commit is contained in:
D0A1V2I3D 2023-02-05 11:35:47 +01:00
commit 731428f798
No known key found for this signature in database
GPG key ID: 70C7C44D1C3EC16F
6 changed files with 126 additions and 0 deletions

16
src/flag_utils.rs Normal file
View file

@ -0,0 +1,16 @@
pub fn get_flags(flags: i32) -> Vec<i32> {
let mut fvec: Vec<bool> = Vec::new();
let mut rest = flags;
while rest != 0 {
fvec.push((rest % 2) != 0);
rest = rest / 2;
}
let mut tvec: Vec<i32> = Vec::new();
for (i, value) in fvec.iter().enumerate() {
if *value {
tvec.push(i as i32);
}
}
tvec
}