Skip to content
This repository has been archived by the owner on May 20, 2022. It is now read-only.

Commit

Permalink
Add support for setting unicode range bitfields
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed May 17, 2022
1 parent c5216dd commit 9466ce1
Show file tree
Hide file tree
Showing 2 changed files with 266 additions and 55 deletions.
7 changes: 7 additions & 0 deletions crates/otspec/src/utils.rs
Expand Up @@ -7,6 +7,13 @@ pub fn int_list_to_num(int_list: &[u8]) -> u32 {
flags
}

/// Convert an array of bits into an integer, but split into a range of U32s
pub fn filtered_bitset_to_num<'a>(bs: impl Iterator<Item = &'a u8>, low: u8, high: u8) -> u32 {
bs.filter(|&x| x >= &low && x <= &high)
.map(|x| 2_i32.pow((x - low).into()) as u32)
.sum()
}

/// Tests if all elements of an iterator have the same content
pub fn is_all_the_same<T, U>(mut iter: T) -> bool
where
Expand Down

1 comment on commit 9466ce1

@m4rc1e
Copy link
Contributor

@m4rc1e m4rc1e commented on 9466ce1 May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! thank you for taking over on this one!

Please sign in to comment.