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

Replace lazy static dep with once cell #158

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Removed `thiserror` dependency in favor of implementing `InquireError` by hand. [#146](https://github.com/mikaelmello/inquire/issues/146)
- Raised MSRV to 1.60 due to `log` dependency raising their MSRV to 1.60.
- MSRV is now explicitly set in the package definition.
- Replaced `lazy_static` with `once_cell` as `once_cell::sync::Lazy` is being standardized and `lazy_static` is not actively maintained anymore.

## [0.6.2] - 2023-05-07

Expand Down
3 changes: 1 addition & 2 deletions inquire/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ tempfile = { version = "3", optional = true }

bitflags = "2"
dyn-clone = "1"
lazy_static = "1.4"
newline-converter = "0.3"

once_cell = "1.18.0"
unicode-segmentation = "1"
unicode-width = "0.1"

Expand Down
8 changes: 3 additions & 5 deletions inquire/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

use std::sync::Mutex;

use lazy_static::lazy_static;
use once_cell::sync::Lazy;

use crate::ui::RenderConfig;

lazy_static! {
static ref GLOBAL_RENDER_CONFIGURATION: Mutex<RenderConfig<'static>> =
Mutex::new(RenderConfig::default());
}
static GLOBAL_RENDER_CONFIGURATION: Lazy<Mutex<RenderConfig<'static>>> =
Lazy::new(|| Mutex::new(RenderConfig::default()));

pub fn get_configuration() -> RenderConfig<'static> {
*GLOBAL_RENDER_CONFIGURATION.lock().unwrap()
Expand Down
6 changes: 2 additions & 4 deletions inquire/src/prompts/editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
ffi::{OsStr, OsString},
};

use lazy_static::lazy_static;
use once_cell::sync::Lazy;

use crate::{
error::{InquireError, InquireResult},
Expand All @@ -22,9 +22,7 @@ use crate::{

use self::prompt::EditorPrompt;

lazy_static! {
static ref DEFAULT_EDITOR: OsString = get_default_editor_command();
}
static DEFAULT_EDITOR: Lazy<OsString> = Lazy::new(get_default_editor_command);

/// This prompt is meant for cases where you need the user to write some text that might not fit in a single line, such as long descriptions or commit messages.
///
Expand Down