Skip to content

Commit

Permalink
chore: clean up deps and remove once_cell
Browse files Browse the repository at this point in the history
  • Loading branch information
hiltontj committed Nov 3, 2024
1 parent eef42a4 commit b96f7d9
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 40 deletions.
18 changes: 10 additions & 8 deletions serde_json_path/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ trace = ["dep:tracing", "serde_json_path_core/trace"]
functions = ["serde_json_path_core/functions"]

[dependencies]
inventory = { version = "0.3.4" }
# crates.io crates:
inventory = { version = "0.3.15" }
nom = "7.1.3"
once_cell = { version = "1.17.1" }
regex = { version="1.7.1", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
regex = { version="1.11.1", optional = true }
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.1"
thiserror = "1.0.67"
tracing = { version = "0.1.40", optional = true }

# local crates:
serde_json_path_core = { path = "../serde_json_path_core", version = "0.1.6" }
serde_json_path_macros = { path = "../serde_json_path_macros", version = "0.1.4" }
thiserror = "1.0"
tracing = { version = "0.1", optional = true }

[dev-dependencies]
test-log = { version = "0.2.11", default-features = false, features=["trace"] }
tracing-subscriber = { version = "0.3", default-features = false, features=["env-filter", "fmt"] }
tracing-subscriber = { version = "0.3.18", default-features = false, features=["env-filter", "fmt"] }
28 changes: 14 additions & 14 deletions serde_json_path/src/parser/selector/function/registry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;
use std::{collections::HashMap, sync::LazyLock};

use once_cell::sync::Lazy;
use serde_json::Value;
use serde_json_path_core::spec::functions::{Function, LogicalType, NodesType, ValueType};

Expand All @@ -15,18 +14,19 @@ use serde_json_path_core::spec::functions::{Function, LogicalType, NodesType, Va
/// the return type for each function registered here. When adding new functions to
/// the register, i.e., when new functions are standardized, the function there needs
/// to be updated too.
pub(crate) static REGISTRY: Lazy<HashMap<&'static str, &'static Function>> = Lazy::new(|| {
let mut m = HashMap::new();
m.insert("length", &LENGTH_FUNC);
m.insert("count", &COUNT_FUNC);
#[cfg(feature = "regex")]
{
m.insert("match", &MATCH_FUNC);
m.insert("search", &SEARCH_FUNC);
}
m.insert("value", &VALUE_FUNC);
m
});
pub(crate) static REGISTRY: LazyLock<HashMap<&'static str, &'static Function>> =
LazyLock::new(|| {
let mut m = HashMap::new();
m.insert("length", &LENGTH_FUNC);
m.insert("count", &COUNT_FUNC);
#[cfg(feature = "regex")]
{
m.insert("match", &MATCH_FUNC);
m.insert("search", &SEARCH_FUNC);
}
m.insert("value", &VALUE_FUNC);
m
});

fn value_length(value: &Value) -> Option<usize> {
match value {
Expand Down
11 changes: 5 additions & 6 deletions serde_json_path_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ trace = ["dep:tracing"]
functions = []

[dependencies]
inventory = { version = "0.3.4" }
once_cell = "1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
tracing = { version = "0.1", optional = true }
inventory = { version = "0.3.15" }
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.1"
thiserror = "1.0.67"
tracing = { version = "0.1.40", optional = true }

[dev-dependencies]
serde_json_path = { path = "../serde_json_path" }
Expand Down
6 changes: 3 additions & 3 deletions serde_json_path_core/src/spec/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@
use std::{
collections::VecDeque,
ops::{Deref, DerefMut},
sync::LazyLock,
};

use once_cell::sync::Lazy;
use serde_json::Value;

use crate::{node::NodeList, spec::query::Queryable};
Expand All @@ -151,11 +151,11 @@ use super::{

#[doc(hidden)]
pub type Validator =
Lazy<Box<dyn Fn(&[FunctionExprArg]) -> Result<(), FunctionValidationError> + Send + Sync>>;
LazyLock<Box<dyn Fn(&[FunctionExprArg]) -> Result<(), FunctionValidationError> + Send + Sync>>;

#[doc(hidden)]
pub type Evaluator =
Lazy<Box<dyn for<'a> Fn(VecDeque<JsonPathValue<'a>>) -> JsonPathValue<'a> + Sync + Send>>;
LazyLock<Box<dyn for<'a> Fn(VecDeque<JsonPathValue<'a>>) -> JsonPathValue<'a> + Sync + Send>>;

#[doc(hidden)]
#[allow(missing_debug_implementations)]
Expand Down
3 changes: 1 addition & 2 deletions serde_json_path_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ keywords = ["json", "jsonpath", "json_path", "serde", "serde_json"]
[lib]

[dependencies]
inventory = "0.3.15"
serde_json_path_macros_internal = { path = "src/internal", version = "0.1.1" }
serde_json_path_core = { path = "../serde_json_path_core", version = "0.1.6" }
inventory = "0.3"
once_cell = "1"

[dev-dependencies]
serde_json = "1"
Expand Down
6 changes: 3 additions & 3 deletions serde_json_path_macros/src/internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ proc-macro = true
path = "mod.rs"

[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0", features = ["full"] }
proc-macro2 = "1.0.89"
quote = "1.0.37"
syn = { version = "2.0.87", features = ["full"] }
2 changes: 1 addition & 1 deletion serde_json_path_macros/src/internal/common/define.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(crate) fn expand(input: ItemFn, name_str: Option<LitStr>) -> Result<Expanded
let args_len = args.len();
// Generate token streams for some needed types:
let lazy = quote! {
::serde_json_path_macros::once_cell::sync::Lazy
std::sync::LazyLock
};
let core = quote! {
::serde_json_path_macros::serde_json_path_core::spec::functions
Expand Down
3 changes: 0 additions & 3 deletions serde_json_path_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,5 @@ pub use serde_json_path_macros_internal::register;
#[doc(hidden)]
pub use ::inventory;

#[doc(hidden)]
pub use ::once_cell;

#[doc(hidden)]
pub use ::serde_json_path_core;

0 comments on commit b96f7d9

Please sign in to comment.