Skip to content

Commit 16104ca

Browse files
authored
Merge branch 'main' into master
2 parents f6beb87 + 5f30873 commit 16104ca

File tree

5 files changed

+68
-18
lines changed

5 files changed

+68
-18
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
<!-- next-header -->
88
## [Unreleased] - ReleaseDate
99

10+
## [0.15.14] - 2025-08-12
11+
12+
### Performance
13+
14+
- *(json5)* Reduce overhead when loading json5 files
15+
1016
## [0.15.13] - 2025-07-09
1117

1218
### Fixes
@@ -591,7 +597,8 @@ update its MSRV.
591597
Initial release.
592598

593599
<!-- next-url -->
594-
[Unreleased]: https://github.com/rust-cli/config-rs/compare/v0.15.13...HEAD
600+
[Unreleased]: https://github.com/rust-cli/config-rs/compare/v0.15.14...HEAD
601+
[0.15.14]: https://github.com/rust-cli/config-rs/compare/v0.15.13...v0.15.14
595602
[0.15.13]: https://github.com/rust-cli/config-rs/compare/v0.15.12...v0.15.13
596603
[0.15.12]: https://github.com/rust-cli/config-rs/compare/v0.15.11...v0.15.12
597604
[0.15.11]: https://github.com/rust-cli/config-rs/compare/v0.15.10...v0.15.11

Cargo.lock

Lines changed: 39 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ lto = true
9797

9898
[package]
9999
name = "config"
100-
version = "0.15.13"
100+
version = "0.15.14"
101101
description = "Layered configuration system for Rust applications."
102102
categories = ["config"]
103103
keywords = ["config", "configuration", "settings", "env", "environment"]
@@ -125,7 +125,7 @@ default = ["toml", "json", "yaml", "ini", "ron", "json5", "convert-case", "async
125125
json = ["serde_json"]
126126
yaml = ["yaml-rust2"]
127127
ini = ["rust-ini"]
128-
json5 = ["json5_rs", "serde/derive"]
128+
json5 = ["json5_rs", "dep:serde-untagged"]
129129
jsonc = ["dep:jsonc-parser"]
130130
convert-case = ["convert_case"]
131131
preserve_order = ["indexmap", "toml?/preserve_order", "serde_json?/preserve_order", "jsonc-parser?/preserve_order", "ron?/indexmap"]
@@ -147,6 +147,7 @@ indexmap = { version = "2.10.0", features = ["serde"], optional = true }
147147
convert_case = { version = "0.6", optional = true }
148148
pathdiff = "0.2"
149149
winnow = "0.7.0"
150+
serde-untagged = { version = "0.1.8", optional = true }
150151

151152
[dev-dependencies]
152153
serde_derive = "1.0"

src/file/format/json5.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use crate::format;
44
use crate::map::Map;
55
use crate::value::{Value, ValueKind};
66

7-
#[derive(serde::Deserialize, Debug)]
8-
#[serde(untagged)]
7+
#[derive(Debug)]
98
pub(crate) enum Val {
109
Null,
1110
Boolean(bool),
@@ -16,6 +15,23 @@ pub(crate) enum Val {
1615
Object(Map<String, Self>),
1716
}
1817

18+
impl<'de> serde::de::Deserialize<'de> for Val {
19+
fn deserialize<D>(d: D) -> Result<Self, D::Error>
20+
where
21+
D: serde::de::Deserializer<'de>,
22+
{
23+
serde_untagged::UntaggedEnumVisitor::new()
24+
.bool(|value| Ok(Self::Boolean(value)))
25+
.i64(|value| Ok(Self::Integer(value)))
26+
.f64(|value| Ok(Self::Float(value)))
27+
.string(|value| Ok(Val::String(value.to_owned())))
28+
.none(|| Ok(Self::Null))
29+
.seq(|value| value.deserialize().map(Val::Array))
30+
.map(|value| value.deserialize().map(Val::Object))
31+
.deserialize(d)
32+
}
33+
}
34+
1935
pub(crate) fn parse(
2036
uri: Option<&String>,
2137
text: &str,

src/ser.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,6 @@ impl ser::SerializeStructVariant for Unreachable {
676676

677677
#[cfg(test)]
678678
mod test {
679-
use serde::{Deserialize, Serialize};
680-
#[cfg(not(feature = "json5"))]
681679
use serde_derive::{Deserialize, Serialize};
682680

683681
use super::*;

0 commit comments

Comments
 (0)