Skip to content

Commit

Permalink
Add documentation on wrap_err vs wrap_err_with (#93)
Browse files Browse the repository at this point in the history
Adds documentation on the difference in performance characteristics between  wrap_err vs wrap_err_with explored in Issue #126

---------

Co-authored-by: Jane Losare-Lusby <[email protected]>
  • Loading branch information
akshayknarayan and yaahc authored Nov 24, 2023
1 parent ef77800 commit 0979ad7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions eyre/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,13 @@ pub type Result<T, E = Report> = core::result::Result<T, E>;
/// # panic!("expected downcast to succeed");
/// }
/// ```
///
/// # `wrap_err` vs `wrap_err_with`
///
/// `wrap_err` incurs a runtime cost even in the non-error case because it requires eagerly
/// constructing the error object. `wrap_err_with` avoids this cost through lazy evaluation. This
/// cost is proportional to the cost of the currently installed [`EyreHandler`]'s creation step.
/// `wrap_err` is useful in cases where an constructed error object already exists.
pub trait WrapErr<T, E>: context::private::Sealed {
/// Wrap the error value with a new adhoc error
#[cfg_attr(track_caller, track_caller)]
Expand Down

0 comments on commit 0979ad7

Please sign in to comment.