Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/error-chain/examples/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 954 B image not shown  

Quelle  size.rs   Sprache: unbekannt

 
#[macro_use]
extern crate error_chain;

use std::mem::{size_of, size_of_val};

error_chain! {
    errors {
        AVariant
        Another
    }
}

fn main() {
    println!("Memory usage in bytes");
    println!("---------------------");
    println!("Result<()>: {}", size_of::<Result<()>>());
    println!("  (): {}", size_of::<()>());
    println!("  Error: {}", size_of::<Error>());
    println!("    ErrorKind: {}", size_of::<ErrorKind>());
    let msg = ErrorKind::Msg("test".into());
    println!("      ErrorKind::Msg: {}", size_of_val(&msg));
    println!("        String: {}", size_of::<String>());
    println!("    State: {}", size_of::<error_chain::State>());
    let state = error_chain::State {
        next_error: None,
        backtrace: error_chain::InternalBacktrace::new(),
    };
    println!("      State.next_error: {}", size_of_val(&state.next_error));
    println!("      State.backtrace: {}", size_of_val(&state.backtrace));
}

[ Dauer der Verarbeitung: 0.15 Sekunden  (vorverarbeitet)  ]