Skip to content

Instantly share code, notes, and snippets.

@aep
Created April 9, 2019 13:32
Show Gist options
  • Save aep/e625c59aa6e2dbad6a56a97211cb8aeb to your computer and use it in GitHub Desktop.
Save aep/e625c59aa6e2dbad6a56a97211cb8aeb to your computer and use it in GitHub Desktop.
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
let mut hasher = DefaultHasher::new();
identity.hash(&mut hasher);
let r = hasher.finish();
if r % shard_count as u64 == shard as u64 {
// work on this thing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment