stacks-core icon indicating copy to clipboard operation
stacks-core copied to clipboard

[refactor] replace lazy_static with LazyLock

Open cylewitruk opened this issue 1 year ago • 2 comments

Resolves #5035 however using std::sync::LazyLock instead of std::cell::LazyCell because most of the values are used as statics (LazyCell is for const-like behavior). Also changed a bunch of .unwrap()s to .expect()s to improve eventual error interpretation.

const + LazyCell could likely be used for a handful of the values, but to determine those the usage of each needs to be evaluated, so I opted for LazyLock for all of them as it most closely mimics static_lazy!.

cylewitruk avatar Aug 07 '24 17:08 cylewitruk

Don't forget to update package.rust-version to 1.80 in Cargo.toml files where LazyLock is used

jbencin avatar Aug 09 '24 14:08 jbencin

@jbencin I think all of your comments are resolved now. Really like const_format, good tip!

I went a step further and reverted to const LazyCell where appropriate, changed a bunch of statics to consts which didn't need to be static and did some other general cleanup.

I added rust-version to the workspace config and added rust-version.workspace = true to all of the package Cargo.toml files -- doesn't really make sense for this project for them to deviate from eachother imo.

cylewitruk avatar Aug 11 '24 17:08 cylewitruk