Replace lazy_static with std::sync::LazyLock (#16066)

Closes #15860 

Since rust std now supports LazyLock replacing lazy_static with it
reduce the external dependency.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
Sinan Gençoğlu 2024-08-20 20:27:33 +02:00 committed by GitHub
parent 85731dfe8e
commit ff7017c308
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 160 additions and 195 deletions

View file

@ -26,7 +26,6 @@ editor.workspace = true
gpui.workspace = true
itertools.workspace = true
language.workspace = true
lazy_static.workspace = true
log.workspace = true
multi_buffer.workspace = true
nvim-rs = { git = "https://github.com/KillTheMule/nvim-rs", branch = "master", features = [

View file

@ -2,25 +2,23 @@ use std::sync::Arc;
use collections::HashMap;
use gpui::AppContext;
use lazy_static::lazy_static;
use settings::Settings;
use std::sync::LazyLock;
use ui::WindowContext;
use crate::{Vim, VimSettings};
mod default;
lazy_static! {
static ref DEFAULT_DIGRAPHS_MAP: HashMap<String, Arc<str>> = {
let mut map = HashMap::default();
for &(a, b, c) in default::DEFAULT_DIGRAPHS {
let key = format!("{a}{b}");
let value = char::from_u32(c).unwrap().to_string().into();
map.insert(key, value);
}
map
};
}
static DEFAULT_DIGRAPHS_MAP: LazyLock<HashMap<String, Arc<str>>> = LazyLock::new(|| {
let mut map = HashMap::default();
for &(a, b, c) in default::DEFAULT_DIGRAPHS {
let key = format!("{a}{b}");
let value = char::from_u32(c).unwrap().to_string().into();
map.insert(key, value);
}
map
});
fn lookup_digraph(a: char, b: char, cx: &AppContext) -> Arc<str> {
let custom_digraphs = &VimSettings::get_global(cx).custom_digraphs;