Skip to content

Commit

Permalink
using std::sync::LazyLock instead of once_cell crate
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 20, 2024
1 parent eff1363 commit 0bcb62a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion fastn-builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ homepage.workspace = true
[dependencies]
regex.workspace = true
indexmap.workspace = true
once_cell.workspace = true
itertools.workspace = true
fastn-type.workspace = true
4 changes: 2 additions & 2 deletions fastn-builtins/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub static FTD_HIGHLIGHTER: once_cell::sync::Lazy<regex::Regex> =
once_cell::sync::Lazy::new(|| regex::Regex::new(r"((;;)( *)(<hl>))( *)(\n?)$").unwrap());
pub static FTD_HIGHLIGHTER: std::sync::LazyLock<regex::Regex> =
std::sync::LazyLock::new(|| regex::Regex::new(r"((;;)( *)(<hl>))( *)(\n?)$").unwrap());

pub const FTD_BREAKPOINT_WIDTH: &str = "ftd#breakpoint-width";
pub const FTD_BREAKPOINT_WIDTH_DATA: &str = "ftd#breakpoint-width-data";
Expand Down
7 changes: 3 additions & 4 deletions fastn-builtins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10887,12 +10887,11 @@ pub fn fastn_test_function() -> fastn_type::ComponentDefinition {
}
}

pub static DEFAULT_BAG: once_cell::sync::OnceCell<
indexmap::IndexMap<String, fastn_type::Definition>,
> = once_cell::sync::OnceCell::new();
pub static DEFAULT_BAG: std::sync::LazyLock<indexmap::IndexMap<String, fastn_type::Definition>> =
std::sync::LazyLock::new(default_bag);

pub fn get_default_bag() -> &'static indexmap::IndexMap<String, fastn_type::Definition> {
DEFAULT_BAG.get_or_init(default_bag)
&DEFAULT_BAG
}

pub fn image_function() -> fastn_type::ComponentDefinition {
Expand Down

0 comments on commit 0bcb62a

Please sign in to comment.