diff --git a/src/iter.rs b/src/iter.rs index b266be22..8032ec35 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -1,4 +1,4 @@ -use super::{IterError, Metadata, SerDe}; +use super::{IterError, Metadata, Miniconf, SerDe}; use core::{fmt::Write, marker::PhantomData}; /// An iterator over the paths in a Miniconf namespace. @@ -32,7 +32,7 @@ impl Default for MiniconfIter { } } -impl + SerDe, S, const L: usize, P, Y> MiniconfIter { +impl + SerDe, S, const L: usize, P, Y> MiniconfIter { pub fn metadata() -> Result { let meta = M::metadata(M::SEPARATOR.len_utf8()); if L < meta.max_depth { diff --git a/src/lib.rs b/src/lib.rs index c55cd608..d9427f20 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -116,14 +116,11 @@ pub struct Metadata { pub count: usize, } -pub trait Style {} pub struct Outer; -impl Style for Outer {} pub struct Inner; -impl Style for Inner {} /// Trait exposing serialization/deserialization of elements by path. -pub trait Miniconf { +pub trait Miniconf { /// Deserialize an element by path. /// /// # Args diff --git a/src/option.rs b/src/option.rs index 3e703158..e4cf3b07 100644 --- a/src/option.rs +++ b/src/option.rs @@ -1,8 +1,5 @@ use super::{Error, Inner, IterError, Metadata, Miniconf, Outer}; -use core::{ - fmt::Write, - ops::{Deref, DerefMut}, -}; +use core::fmt::Write; /// An `Option` that exposes its value through their [`Miniconf`] implementation. /// @@ -32,20 +29,7 @@ use core::{ /// /// An `miniconf::Option` can be constructed using [`From`]/[`Into`] /// and the contained value can be accessed through [`Deref`]/[`DerefMut`]. -#[derive( - Clone, - Copy, - Default, - PartialEq, - Eq, - Debug, - PartialOrd, - Ord, - Hash, - serde::Serialize, - serde::Deserialize, -)] -#[repr(transparent)] + pub type Option = core::option::Option; impl> Miniconf for Option { @@ -58,7 +42,7 @@ impl> Miniconf for Option { P: Iterator, D: serde::Deserializer<'b>, { - if let Some(inner) = self.0.as_mut() { + if let Some(inner) = self.as_mut() { inner.set_path(path_parts, de) } else { Err(Error::PathAbsent) @@ -70,7 +54,7 @@ impl> Miniconf for Option { P: Iterator, S: serde::Serializer, { - if let Some(inner) = self.0.as_ref() { + if let Some(inner) = self.as_ref() { inner.get_path(path_parts, ser) } else { Err(Error::PathAbsent) diff --git a/tests/option.rs b/tests/option.rs index 600375ed..d457f322 100644 --- a/tests/option.rs +++ b/tests/option.rs @@ -51,7 +51,7 @@ fn option_get_set_some() { assert_eq!(&data[..len], b"5"); settings.set("/value/data", b"7").unwrap(); - assert_eq!((*settings.value).as_ref().unwrap().data, 7); + assert_eq!(settings.value.as_ref().unwrap().data, 7); } #[test]