-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make saving of ui optional, add proper return types
- Loading branch information
Showing
3 changed files
with
154 additions
and
78 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
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 |
---|---|---|
@@ -1,4 +1,13 @@ | ||
use sha2::{Digest, Sha256}; | ||
|
||
|
||
pub fn vec_to_arr<T, const N: usize>(v: Vec<T>) -> [T; N] { | ||
v.try_into() | ||
.unwrap_or_else(|v: Vec<T>| panic!("Expected a Vec of length {} but it was {}", N, v.len())) | ||
} | ||
|
||
pub fn hash_bytes_sha256(bytes: Vec<u8>) -> String { | ||
let mut hasher = Sha256::new(); | ||
hasher.update(bytes); | ||
hex::encode(hasher.finalize()) | ||
} |