fix vec trail
This commit is contained in:
commit
731428f798
6 changed files with 126 additions and 0 deletions
16
src/flag_utils.rs
Normal file
16
src/flag_utils.rs
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue