Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use LazyLock instead of now deprecated lazy_static #2049

Open
grumbach opened this issue Aug 19, 2024 · 0 comments
Open

Use LazyLock instead of now deprecated lazy_static #2049

grumbach opened this issue Aug 19, 2024 · 0 comments
Labels
Dependencies Pull requests that update a dependency file Enhancement New feature or request good-starter-issue Good issues for new contributors rust Pull requests that update Rust code

Comments

@grumbach
Copy link
Member

Remove lazy_static = "1.4.0" dependency in all our Cargo.toml

And replace code using lazy_static:

#[macro_use]
extern crate lazy_static;

lazy_static! {
    static ref CONFIG: Config = {
        // Some expensive initialization
        Config::new()
    };
}

fn main() {
    println!("{:?}", *CONFIG);
}

by using LazyLock

use std::sync::LazyLock;

static CONFIG: LazyLock<Config> = LazyLock::new(|| {
    // Some expensive initialization
    Config::new()
});

fn main() {
    println!("{:?}", *CONFIG);
}
@grumbach grumbach added Enhancement New feature or request Dependencies Pull requests that update a dependency file rust Pull requests that update Rust code good-starter-issue Good issues for new contributors labels Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dependencies Pull requests that update a dependency file Enhancement New feature or request good-starter-issue Good issues for new contributors rust Pull requests that update Rust code
Projects
None yet
Development

No branches or pull requests

1 participant