Skip to content

Commit f419c5c

Browse files
Ditch id generator
1 parent 2d3e10f commit f419c5c

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

structopt-derive/src/attrs.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,15 @@ impl Attrs {
312312
https://docs.rs/structopt/0.3.5/structopt/#magical-methods")
313313
};
314314

315-
let static_name = format_ident!("__STRUCTOPT_DEFAULT_VALUE_{}", fresh_id());
316-
317315
quote_spanned!(ident.span()=> {
318316
::structopt::lazy_static::lazy_static! {
319-
static ref #static_name: &'static str = {
317+
static ref DEFAULT_VALUE: &'static str = {
320318
let val = <#ty as ::std::default::Default>::default();
321319
let s = ::std::string::ToString::to_string(&val);
322320
::std::boxed::Box::leak(s.into_boxed_str())
323321
};
324322
}
325-
*#static_name
323+
*DEFAULT_VALUE
326324
})
327325
};
328326

@@ -642,20 +640,6 @@ impl Attrs {
642640
}
643641
}
644642

645-
fn fresh_id() -> usize {
646-
use std::cell::Cell;
647-
648-
thread_local! {
649-
static NEXT_ID: Cell<usize> = Cell::new(0);
650-
}
651-
652-
NEXT_ID.with(|next_id| {
653-
let id = next_id.get();
654-
next_id.set(id + 1);
655-
id
656-
})
657-
}
658-
659643
/// replace all `:` with `, ` when not inside the `<>`
660644
///
661645
/// `"author1:author2:author3" => "author1, author2, author3"`

0 commit comments

Comments
 (0)