Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit ad9a52e

Browse files
committed
Simplify the conditionnal compilation.
1 parent f768c42 commit ad9a52e

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/lib.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl<T, E> ResultExt<T, E> for Result<T, E> where E: ChainedError {
389389
EK: Into<E::ErrorKind> {
390390
self.map_err(move |e| {
391391
#[cfg(feature = "backtrace")]
392-
let ret = {
392+
let error = {
393393
let backtrace = E::extract_backtrace(&e)
394394
.unwrap_or_else(make_backtrace);
395395
E::new(callback().into(), State {
@@ -398,12 +398,10 @@ impl<T, E> ResultExt<T, E> for Result<T, E> where E: ChainedError {
398398
})
399399
};
400400
#[cfg(not(feature = "backtrace"))]
401-
let ret = {
402-
E::new(callback().into(), State {
403-
next_error: Some(Box::new(e)),
404-
})
405-
};
406-
ret
401+
let error = E::new(callback().into(), State {
402+
next_error: Some(Box::new(e)),
403+
});
404+
error
407405
})
408406
}
409407
}
@@ -419,21 +417,17 @@ pub struct State {
419417
pub backtrace: Option<Arc<Backtrace>>,
420418
}
421419

422-
#[cfg(feature = "backtrace")]
423420
impl Default for State {
424421
fn default() -> State {
425-
State {
422+
#[cfg(feature = "backtrace")]
423+
let state = State {
426424
next_error: None,
427425
backtrace: make_backtrace(),
428-
}
429-
}
430-
}
431-
432-
#[cfg(not(feature = "backtrace"))]
433-
impl Default for State {
434-
fn default() -> State {
435-
State {
426+
};
427+
#[cfg(not(feature = "backtrace"))]
428+
let state = State {
436429
next_error: None,
437-
}
430+
};
431+
state
438432
}
439433
}

0 commit comments

Comments
 (0)