62FAY63A6J5JJOX2RHKOWKFCJ6SHAPJT67CQ4ZJ7EXCPH6QVTW5QC
E5ATLVVXDN4OH5PC7NETGYSIEFAP6DNA2XGR2OQSLO4B7BQNRULQC
BZSTVYDVHJA3ZMCM3YTU4U5JKJC2JVUDM5APSBIGMSS54J2C4WKQC
OTLOFVIUXGUQQKEFKNJXUP7NRMAMJV2YOTECX5MBN5CKP4QWRVVQC
CITEDKPB6MKVZUEYEDE5ZKTNVY35HCOAXKDPYG7YLLEOVFNMSRXQC
GZZOJ7ZUSBPI3HXIV5UCFNMCDAMZPPLISY2UDV73FDN74HZ3AWJAC
5F7NROZAWXVVAHQH7P55L5WUTZ6YJ3SFPWCMJSTEOXAF3ULFK7RAC
LSRQCHOX2IW72XT5S4XAF4MCCXADODHVIA3UCHYRJGRSQEPFMULAC
W655S25G7CGI4XOZ2PKITKTH26VJ4QMZFRV2RPYNI4KIUJOIGVMAC
UM7DFUYLW4HSMBUDZY3R6ZNJRSX2E75C4DYV3MJAU57EUCGE6JLAC
YSGVTU4ZVGBOLP5N3FBH76PSNWD5T4CHKWRF52GVERFQO4GLZD6AC
}
}
#[cfg(test)]
mod repr_correctness {
use super::*;
use std::marker::Unpin;
use std::mem;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::Arc;
#[test]
fn size_of_error() {
assert_eq!(mem::size_of::<Error>(), mem::size_of::<usize>());
}
#[test]
fn error_autotraits() {
fn assert<E: Unpin + Send + Sync + 'static>() {}
assert::<Error>();
}
#[test]
fn drop_works() {
#[derive(Debug)]
struct DetectDrop {
has_dropped: Arc<AtomicBool>,
}
impl StdError for DetectDrop {}
impl Display for DetectDrop {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "does something")
}
}
impl Drop for DetectDrop {
fn drop(&mut self) {
let already_dropped = self.has_dropped.swap(true, SeqCst);
assert!(!already_dropped);
}
}
let has_dropped = Arc::new(AtomicBool::new(false));
drop(Error::new(DetectDrop {
has_dropped: has_dropped.clone(),
}));
assert!(has_dropped.load(SeqCst));
use anyhow::Error;
use std::error::Error as StdError;
use std::fmt::{self, Display};
use std::marker::Unpin;
use std::mem;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::Arc;
#[test]
fn size_of_error() {
assert_eq!(mem::size_of::<Error>(), mem::size_of::<usize>());
}
#[test]
fn error_autotraits() {
fn assert<E: Unpin + Send + Sync + 'static>() {}
assert::<Error>();
}
#[test]
fn drop_works() {
#[derive(Debug)]
struct DetectDrop {
has_dropped: Arc<AtomicBool>,
}
impl StdError for DetectDrop {}
impl Display for DetectDrop {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "does something")
}
}
impl Drop for DetectDrop {
fn drop(&mut self) {
let already_dropped = self.has_dropped.swap(true, SeqCst);
assert!(!already_dropped);
}
}
let has_dropped = Arc::new(AtomicBool::new(false));
drop(Error::new(DetectDrop {
has_dropped: has_dropped.clone(),
}));
assert!(has_dropped.load(SeqCst));
}