Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  component_range.rs

  Sprache: Rust
 

//! Component range error

use core::fmt;

use crate::error;

/// An error type indicating that a component provided to a method was out of range, causing a
/// failure.
// i64 is the narrowest type fitting all use cases. This eliminates the need for a type parameter.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ComponentRange {
    /// Name of the component.
    pub(crate) name: &'static str,
    /// Whether an input with the same value could have succeeded if the values of other components
    /// were different.
    pub(crate) is_conditional: bool,
}

impl ComponentRange {
    /// Create a new `ComponentRange` error that is not conditional.
    #[inline]
    pub(crateconst fn unconditional(name: &'static str) -> Self {
        Self {
            name,
            is_conditional: false,
        }
    }

    /// Create a new `ComponentRange` error that is conditional.
    #[inline]
    pub(crateconst fn conditional(name: &'static str) -> Self {
        Self {
            name,
            is_conditional: true,
        }
    }

    /// Obtain the name of the component whose value was out of range.
    #[inline]
    pub const fn name(self) -> &'static str {
        self.name
    }

    /// Whether the value's permitted range is conditional, i.e. whether an input with this
    /// value could have succeeded if the values of other components were different.
    #[inline]
    pub const fn is_conditional(self) -> bool {
        self.is_conditional
    }
}

impl fmt::Display for ComponentRange {
    #[inline]
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{} was not in range"self.name)
    }
}

impl From<ComponentRange> for crate::Error {
    #[inline]
    fn from(original: ComponentRange) -> Self {
        Self::ComponentRange(original)
    }
}

impl TryFrom<crate::Error> for ComponentRange {
    type Error = error::DifferentVariant;

    #[inline]
    fn try_from(err: crate::Error) -> Result<SelfSelf::Error> {
        match err {
            crate::Error::ComponentRange(err) => Ok(err),
            _ => Err(error::DifferentVariant),
        }
    }
}

/// **This trait implementation is deprecated and will be removed in a future breaking release.**
#[cfg(feature = "serde")]
impl serde_core::de::Expected for ComponentRange {
    #[inline]
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str("an in-range value")
    }
}

#[cfg(feature = "serde")]
impl ComponentRange {
    /// Convert the error to a deserialization error.
    #[inline]
    pub(cratefn into_de_error<E>(self) -> E
    where
        E: serde_core::de::Error,
    {
        serde_core::de::Error::custom(format_args!(
            "invalid {}, expected an in-range value",
            self.name
        ))
    }
}

impl core::error::Error for ComponentRange {}

Messung V0.5 in Prozent
C=81 H=100 G=90

¤ Dauer der Verarbeitung: 0.14 Sekunden  (vorverarbeitet am  2026-08-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=434850
#Domains=661743