forked from anoma/ferveo
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cfe558
commit 98c49d1
Showing
5 changed files
with
32 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
pub mod keypair; | ||
pub mod serialization; | ||
pub mod utils; | ||
|
||
pub use keypair::*; | ||
pub use serialization::*; | ||
pub use utils::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
pub fn is_power_of_2(n: u32) -> bool { | ||
n != 0 && (n & (n - 1)) == 0 | ||
} | ||
|
||
pub fn is_sorted<I>(data: I) -> bool | ||
where | ||
I: IntoIterator, | ||
I::Item: Ord, | ||
{ | ||
let mut data = data.into_iter(); | ||
let mut prev = match data.next() { | ||
None => return true, | ||
Some(x) => x, | ||
}; | ||
for x in data { | ||
if prev > x { | ||
return false; | ||
} | ||
prev = x; | ||
} | ||
true | ||
} |