]>
git.proxmox.com Git - rustc.git/blob - src/vendor/error-chain/examples/size.rs
2 extern crate error_chain
;
4 use std
::mem
::{size_of, size_of_val}
;
14 println
!("Memory usage in bytes");
15 println
!("---------------------");
16 println
!("Result<()>: {}", size_of
::<Result
<()>>());
17 println
!(" (): {}", size_of
::<()>());
18 println
!(" Error: {}", size_of
::<Error
>());
19 println
!(" ErrorKind: {}", size_of
::<ErrorKind
>());
20 let msg
= ErrorKind
::Msg("test".into());
21 println
!(" ErrorKind::Msg: {}", size_of_val(&msg
));
22 println
!(" String: {}", size_of
::<String
>());
23 println
!(" State: {}", size_of
::<error_chain
::State
>());
24 #[cfg(feature = "backtrace")]
26 let state
= error_chain
::State
{
30 println
!(" State.next_error: {}", size_of_val(&state
.next_error
));
31 println
!(" State.backtrace: {}", size_of_val(&state
.backtrace
));
33 #[cfg(not(feature = "backtrace"))]
35 let state
= error_chain
::State
{
38 println
!(" State.next_error: {}", size_of_val(&state
.next_error
));