Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Threema/domain/libthreema/lib/src/csp/payload/     Datei vom 25.3.2026 mit Größe 14 kB image not shown  

SSL child.rs   Sprache: Rust

 

use proc_macro2::Span;

/// Exhaustive mirror of [`proc_macro::Level`].
#[derive(Debug, Clone)]
pub(in crate::error) enum Level {
    Error,
    Warning,
    Note,
    Help,
}

/// Supplemental message for an [`Error`](super::Error) when it's emitted as a `Diagnostic`.
///
/// # Example Output
/// The `note` and `help` lines below come from child diagnostics.
///
/// ```text
/// error: My custom error
///   --> my_project/my_file.rs:3:5
///    |
/// 13 |     FooBar { value: String },
///    |     ^^^^^^
///    |
///    = note: My note on the macro usage
///    = help: Try doing this instead
/// ```
#[derive(Debug, Clone)]
pub(in crate::error) struct ChildDiagnostic {
    level: Level,
    span: Option<Span>,
    message: String,
}

impl ChildDiagnostic {
    pub(in crate::error) fn new(level: Level, span: Option<Span>, message: String) -> Self {
        Self {
            level,
            span,
            message,
        }
    }
}

impl ChildDiagnostic {
    /// Append this child diagnostic to a `Diagnostic`.
    ///
    /// # Panics
    /// This method panics if `self` has a span and is being invoked outside of
    /// a proc-macro due to the behavior of [`Span::unwrap()`](Span).
    pub fn append_to(self, diagnostic: proc_macro::Diagnostic) -> proc_macro::Diagnostic {
        match self.level {
            Level::Error => {
                if let Some(span) = self.span {
                    diagnostic.span_error(span.unwrap(), self.message)
                } else {
                    diagnostic.error(self.message)
                }
            }
            Level::Warning => {
                if let Some(span) = self.span {
                    diagnostic.span_warning(span.unwrap(), self.message)
                } else {
                    diagnostic.warning(self.message)
                }
            }
            Level::Note => {
                if let Some(span) = self.span {
                    diagnostic.span_note(span.unwrap(), self.message)
                } else {
                    diagnostic.note(self.message)
                }
            }
            Level::Help => {
                if let Some(span) = self.span {
                    diagnostic.span_help(span.unwrap(), self.message)
                } else {
                    diagnostic.help(self.message)
                }
            }
        }
    }
}

Messung V0.5 in Prozent
C=97 H=94 G=95

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© 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.