Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixes
* ci: Check the tests pass with `-Zminimal-versions`

### Added
* Implement slog::Value for `std::sync::LazyLock` and `std::cell::LazyCell`.

## 2.8.1 - 2025-10-05
This fixes an accidental breaking change in the v2.8.0 release,
where the public API was changed from `erased_serde v0.4` to `erased_serde v0.3`.
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ release_max_level_trace = []
serde_core = { version = "1", optional = true, default-features = false }
anyhow = { version = "1", optional = true, default-features = false }
parking_lot_0_12 = { package = "parking_lot", version = "0.12", optional = true }
# NOTE: This is just a macro (not a runtime dependency)
#
# It is used to conditionally enable use of newer rust language
# features depending on the compiler features.
rustversion = "1.0.6"

[dependencies.erased-serde]
# For Slog 2.x, we keep compat with `erased-serde 0.3` as it's a public
Expand All @@ -122,11 +127,6 @@ features = ["alloc"] # erased-serde always requires alloc, and so does slog
rustversion = "1.0.6"

[dev-dependencies]
# NOTE: This is just a macro (not a runtime dependency)
#
# It is used to conditionally enable use of newer rust language
# features depending on the compiler features.
rustversion = "1.0.6"
# first version to support serde_core
serde = "1.0.220"
serde_derive = "1.0.220"
Expand Down
25 changes: 25 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3325,6 +3325,31 @@ where
}
}

#[cfg(feature = "std")]
#[rustversion::since(1.80)]
impl<T: Value, F: FnOnce() -> T> Value for std::sync::LazyLock<T, F> {
fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer,
) -> Result {
(**self).serialize(record, key, serializer)
}
}

#[rustversion::since(1.80)]
impl<T: Value, F: FnOnce() -> T> Value for std::cell::LazyCell<T, F> {
fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer,
) -> Result {
(**self).serialize(record, key, serializer)
}
}

#[cfg(feature = "std")]
impl Value for std::path::Display<'_> {
fn serialize(
Expand Down
Loading