mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
Seed RNG with package name and prepend string to full random name.
This commit is contained in:
parent
82c533cbf4
commit
a654d13eef
1 changed files with 8 additions and 2 deletions
|
@ -1998,7 +1998,12 @@ struct IdentGenerator {
|
|||
|
||||
impl IdentGenerator {
|
||||
fn new() -> IdentGenerator {
|
||||
IdentGenerator { rng: rand::rngs::SmallRng::seed_from_u64(0) }
|
||||
let crate_name = env!("CARGO_PKG_NAME");
|
||||
let seed = [0u8; 16];
|
||||
for (i, b) in crate_name.bytes().enumerate() {
|
||||
seed[i%seed.len()].wrapping_add(b);
|
||||
}
|
||||
IdentGenerator { rng: rand::rngs::SmallRng::from_seed(seed) }
|
||||
}
|
||||
|
||||
fn mk_ident(&mut self, name: Option<&str>) -> Ident {
|
||||
|
@ -2007,8 +2012,9 @@ impl IdentGenerator {
|
|||
n = 4;
|
||||
format!("{}_", name)
|
||||
} else {
|
||||
let crate_name = env!("CARGO_PKG_NAME").replace("-", "_").to_lowercase();
|
||||
n = 16;
|
||||
String::new()
|
||||
format!("{}__internal__", crate_name)
|
||||
};
|
||||
|
||||
for i in 0..n {
|
||||
|
|
Loading…
Reference in a new issue