oh_my_toml 0.1.0

Awesome TOML configuration derive macro
Documentation
//! Traits that cannot fail

use crate::{DeserializeValue, Key, Value};
use nonempty::NonEmpty;

/// Infallible error
//
// NOTE: We do not want to panic here. The `InfallibleError` cannot occur naturally,
// however someone can still just do `<DeValue as DeserializeValue>::Error::expected_type()`
//
#[derive(miette::Diagnostic, thiserror::Error, Debug, Clone, Eq, PartialEq, Hash, Copy)]
#[error("!")]
pub struct InfallibleError;

impl crate::Error for InfallibleError {
    fn expected_type() -> std::borrow::Cow<'static, str> {
        "!".into()
    }
}

impl<'de> DeserializeValue<'de> for toml::de::DeValue<'de> {
    type Error = InfallibleError;

    fn deserialize_value<'k>(
        _key: Key<'k>,
        value: Value<'de>,
    ) -> Result<Self, crate::DeserializeErrors<Self, NonEmpty<Self::Error>>> {
        Ok(value.into_inner())
    }
}

impl<T> DeserializeValue<'_> for std::marker::PhantomData<T> {
    type Error = InfallibleError;
    fn deserialize_value(
        _key: Key,
        _value: Value,
    ) -> Result<Self, crate::DeserializeErrors<Self, NonEmpty<Self::Error>>> {
        Ok(Self)
    }
}