Skip to content

Instantly share code, notes, and snippets.

@ptdecker
Created July 15, 2025 14:08
Show Gist options
  • Save ptdecker/420242a0217042c6c9110036b3b0525b to your computer and use it in GitHub Desktop.
Save ptdecker/420242a0217042c6c9110036b3b0525b to your computer and use it in GitHub Desktop.
Incorrect type identification
impl ConsumerId {
pub fn new() -> Self {
#[cfg(not(feature = "string-consumer-id"))]
let consumer_id = Uuid::new_v4();
#[cfg(feature = "string-consumer-id")]
let consumer_id = {
let length = 10;
let mut rng = rand::thread_rng();
let letters: Vec<char> = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect();
(0..length)
.map(|_| {
let random_index = rng.gen_range(0..letters.len());
letters[random_index]
})
.collect()
};
Self { id: consumer_id }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment