typeshaper 0.1.4

TypeScript utility-type idioms (Omit, Pick, Merge, Partial…) for Rust structs — one-line type algebra expressions
Documentation
use std::fmt;

/// Error returned by `TryFrom` implementations generated by `typex!(Target = T!)`.
///
/// Carries the name of the first `Option`-wrapped field that was `None` when
/// attempting to convert a `Partial` type back into its `Required` form.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct RequiredError {
    /// Name of the field that was `None`.
    pub field: &'static str,
}

impl RequiredError {
    #[doc(hidden)]
    pub const fn new(field: &'static str) -> Self {
        Self { field }
    }
}

impl fmt::Display for RequiredError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "required field `{}` is None", self.field)
    }
}

impl std::error::Error for RequiredError {}