Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
ugh format again
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkakkar committed May 30, 2024
1 parent a771c62 commit d01a731
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions feature-flags/src/flag_matching.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::flag_definitions::{FeatureFlag, FlagGroupType};
use sha1::{Digest, Sha1};
use std::fmt::Write;
use crate::flag_definitions::{FeatureFlag, FlagGroupType};

#[derive(Debug, PartialEq, Eq)]
pub struct FeatureFlagMatch {
Expand Down Expand Up @@ -136,12 +136,11 @@ impl FeatureFlagMatcher {
let result = hasher.finalize();
// :TRICKY: Convert the first 15 characters of the digest to a hexadecimal string
// not sure if this is correct, padding each byte as 2 characters
let hex_str: String = result
.iter()
.fold(String::new(), |mut acc, byte| {
let _ = write!(acc, "{:02x}", byte);
acc
})[..15].to_string();
let hex_str: String = result.iter().fold(String::new(), |mut acc, byte| {
let _ = write!(acc, "{:02x}", byte);
acc
})[..15]
.to_string();
let hash_val = u64::from_str_radix(&hex_str, 16).unwrap();

hash_val as f64 / LONG_SCALE as f64
Expand Down

0 comments on commit d01a731

Please sign in to comment.