From 05d7bed9e405d83e417d1748e03888976974ef4c Mon Sep 17 00:00:00 2001 From: KodrAus Date: Wed, 31 Jan 2024 10:42:32 +1000 Subject: [PATCH] fill in visitor for inline value --- Cargo.toml | 4 ++-- src/kv/value.rs | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 690f25cee..c30944c56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ kv_unstable_serde = ["kv_unstable_std", "value-bag/serde", "serde"] serde = { version = "1.0", optional = true, default-features = false } sval = { version = "2.1", optional = true, default-features = false } sval_ref = { version = "2.1", optional = true, default-features = false } -value-bag = { version = "1.4", optional = true, default-features = false, features = ["inline-i128"] } +value-bag = { version = "1.7", optional = true, default-features = false, features = ["inline-i128"] } [dev-dependencies] serde = { version = "1.0", features = ["derive"] } @@ -65,7 +65,7 @@ serde_json = "1.0" serde_test = "1.0" sval = { version = "2.1" } sval_derive = { version = "2.1" } -value-bag = { version = "1.4", features = ["test"] } +value-bag = { version = "1.7", features = ["test"] } # NOTE: log doesn't actually depent on this crate. However our dependencies, # serde and sval, dependent on version 1.0 of the crate, which has problem fixed diff --git a/src/kv/value.rs b/src/kv/value.rs index f5f4fc057..2a16f192c 100644 --- a/src/kv/value.rs +++ b/src/kv/value.rs @@ -611,6 +611,10 @@ pub(in crate::kv) mod inner { .map_err(crate::kv::Error::into_value) } + fn visit_empty(&mut self) -> Result<(), Error> { + self.0.visit_null().map_err(crate::kv::Error::into_value) + } + fn visit_u64(&mut self, value: u64) -> Result<(), Error> { self.0 .visit_u64(value) @@ -1005,8 +1009,20 @@ pub(in crate::kv) mod inner { } } - pub fn visit<'v>(inner: &Inner<'v>, visitor: impl Visitor<'v>) -> Result<(), crate::kv::Error> { - todo!() + pub fn visit<'v>(inner: &Inner<'v>, mut visitor: impl Visitor<'v>) -> Result<(), crate::kv::Error> { + match inner { + Inner::None => visitor.visit_null(), + Inner::Bool(v) => visitor.visit_bool(*v), + Inner::Str(v) => visitor.visit_borrowed_str(*v), + Inner::Char(v) => visitor.visit_char(*v), + Inner::I64(v) => visitor.visit_i64(*v), + Inner::U64(v) => visitor.visit_u64(*v), + Inner::F64(v) => visitor.visit_f64(*v), + Inner::I128(v) => visitor.visit_i128(*v), + Inner::U128(v) => visitor.visit_u128(*v), + Inner::Debug(v) => visitor.visit_any(Value::from_dyn_debug(*v)), + Inner::Display(v) => visitor.visit_any(Value::from_dyn_display(*v)), + } } }