Skip to content

Commit

Permalink
fill in visitor for inline value
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Jan 31, 2024
1 parent 54c34f7 commit 05d7bed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ 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"] }
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
Expand Down
20 changes: 18 additions & 2 deletions src/kv/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)),
}
}
}

Expand Down

0 comments on commit 05d7bed

Please sign in to comment.