Skip to content
Myr

Rename as_error to as_dyn_error

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent eac05d1 · Browse files · 4 files+34 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+34 added−34 removed

  • other:+34 added−34 removed

4 files+34 added−34 removed

added:src/as_dyn_error.rs+30 added
1use std::error::Error as StdError;23use crate::Error;45/// View error as a `&dyn std::error::Error`.6pub trait AsDynError {7 /// View type as an error object.8 fn as_dyn_error(&self) -> &(dyn StdError + Send + Sync + 'static);9}1011impl<T> AsDynError for T12where13 T: StdError + Send + Sync + 'static,14{15 fn as_dyn_error(&self) -> &(dyn StdError + Send + Sync + 'static) {16 self17 }18}1920impl AsDynError for dyn StdError + Send + Sync + 'static {21 fn as_dyn_error(&self) -> &(dyn StdError + Send + Sync + 'static) {22 self23 }24}2526impl AsDynError for Error {27 fn as_dyn_error(&self) -> &(dyn StdError + Send + Sync + 'static) {28 &**self29 }30}
deleted:src/as_error.rs-30 removed
1use std::error::Error as StdError;23use crate::Error;45/// View type as an error object.6pub trait AsError {7 /// View type as an error object.8 fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static);9}1011impl<T> AsError for T12where13 T: StdError + Send + Sync + 'static,14{15 fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static) {16 self17 }18}1920impl AsError for dyn StdError + Send + Sync + 'static {21 fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static) {22 self23 }24}2526impl AsError for Error {27 fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static) {28 &**self29 }30}
modified:src/error.rs+2 added-2 removed
65 unmodified lines
66 }67 }6869 /// View this error object as the underlying error.70 pub fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static) {70 pub fn as_dyn_error(&self) -> &(dyn StdError + Send + Sync + 'static) {71 &**self72 }7374 /// View this error object as the underlying error, mutably.75 pub fn as_error_mut(&mut self) -> &mut (dyn StdError + Send + Sync + 'static) {75 pub fn as_dyn_error_mut(&mut self) -> &mut (dyn StdError + Send + Sync + 'static) {76 &mut **self77 }7879 /// Get the backtrace for this Error.
262 unmodified lines
modified:src/lib.rs+2 added-2 removed
1#![feature(backtrace)]23mod as_error;3mod as_dyn_error;4mod context;5mod error;67pub use crate::as_error::AsError;7pub use crate::as_dyn_error::AsDynError;8pub use crate::context::Context;9pub use crate::error::{Error, Errors};1011/// `Result<T, Error>`
22 unmodified lines