Skip to content

Commit

Permalink
fix up some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Jan 31, 2024
1 parent 05d7bed commit e711b62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
20 changes: 11 additions & 9 deletions src/kv/error.rs
@@ -1,7 +1,5 @@
use std::fmt;

use crate::kv::value;

/// An error encountered while working with structured data.
#[derive(Debug)]
pub struct Error {
Expand All @@ -13,7 +11,8 @@ enum Inner {
#[cfg(feature = "std")]
Boxed(std_support::BoxedError),
Msg(&'static str),
Value(value::inner::Error),
#[cfg(feature = "value-bag")]
Value(crate::kv::value::inner::Error),
Fmt,
}

Expand All @@ -25,21 +24,23 @@ impl Error {
}
}

// Not public so we don't leak the `value::inner` API
pub(super) fn from_value(err: value::inner::Error) -> Self {
// Not public so we don't leak the `crate::kv::value::inner` API
#[cfg(feature = "value-bag")]
pub(super) fn from_value(err: crate::kv::value::inner::Error) -> Self {
Error {
inner: Inner::Value(err),
}
}

// Not public so we don't leak the `value::inner` API
pub(super) fn into_value(self) -> value::inner::Error {
// Not public so we don't leak the `crate::kv::value::inner` API
#[cfg(feature = "value-bag")]
pub(super) fn into_value(self) -> crate::kv::value::inner::Error {
match self.inner {
Inner::Value(err) => err,
#[cfg(feature = "kv_unstable_std")]
_ => value::inner::Error::boxed(self),
_ => crate::kv::value::inner::Error::boxed(self),
#[cfg(not(feature = "kv_unstable_std"))]
_ => value::inner::Error::msg("error inspecting a value"),
_ => crate::kv::value::inner::Error::msg("error inspecting a value"),
}
}
}
Expand All @@ -50,6 +51,7 @@ impl fmt::Display for Error {
match &self.inner {
#[cfg(feature = "std")]
Boxed(err) => err.fmt(f),
#[cfg(feature = "value-bag")]
Value(err) => err.fmt(f),
Msg(msg) => msg.fmt(f),
Fmt => fmt::Error.fmt(f),
Expand Down
17 changes: 1 addition & 16 deletions src/kv/value.rs
Expand Up @@ -716,7 +716,7 @@ pub(in crate::kv) mod inner {
}

impl<'v> From<()> for Inner<'v> {
fn from(v: ()) -> Self {
fn from(_: ()) -> Self {
Inner::None
}
}
Expand Down Expand Up @@ -994,21 +994,6 @@ pub(in crate::kv) mod inner {
U64(u64),
}

#[derive(Debug)]
pub struct Error {}

impl Error {
pub fn msg(msg: &'static str) -> Self {
todo!()
}
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
todo!()
}
}

pub fn visit<'v>(inner: &Inner<'v>, mut visitor: impl Visitor<'v>) -> Result<(), crate::kv::Error> {
match inner {
Inner::None => visitor.visit_null(),
Expand Down

0 comments on commit e711b62

Please sign in to comment.