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
Provenance
- Commit
895d383- Tree
e7fd4a3- Author
David Tolnay <dtolnay@gmail.com>- Committer
David Tolnay <dtolnay@gmail.com>- Parent
eac05d1
4 files changed+34 added−34 removed
added:src/as_dyn_error.rs+30 added
1+use std::error::Error as StdError;2+3+use crate::Error;4+5+/// View error as a `&dyn std::error::Error`.6+pub trait AsDynError {7+ /// View type as an error object.8+ fn as_dyn_error(&self) -> &(dyn StdError + Send + Sync + 'static);9+}10+11+impl<T> AsDynError for T12+where13+ T: StdError + Send + Sync + 'static,14+{15+ fn as_dyn_error(&self) -> &(dyn StdError + Send + Sync + 'static) {16+ self17+ }18+}19+20+impl AsDynError for dyn StdError + Send + Sync + 'static {21+ fn as_dyn_error(&self) -> &(dyn StdError + Send + Sync + 'static) {22+ self23+ }24+}25+26+impl AsDynError for Error {27+ fn as_dyn_error(&self) -> &(dyn StdError + Send + Sync + 'static) {28+ &**self29+ }30+}deleted:src/as_error.rs-30 removed
1-use std::error::Error as StdError;2-3-use crate::Error;4-5-/// View type as an error object.6-pub trait AsError {7- /// View type as an error object.8- fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static);9-}10-11-impl<T> AsError for T12-where13- T: StdError + Send + Sync + 'static,14-{15- fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static) {16- self17- }18-}19-20-impl AsError for dyn StdError + Send + Sync + 'static {21- fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static) {22- self23- }24-}25-26-impl 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 lines66 }67 }68 69 /// 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 }73 74 /// 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 }78 79 /// Get the backtrace for this Error.262 unmodified linesmodified:src/lib.rs+2 added-2 removed
1 #![feature(backtrace)]2 3-mod as_error;3+mod as_dyn_error;4 mod context;5 mod error;6 7-pub use crate::as_error::AsError;7+pub use crate::as_dyn_error::AsDynError;8 pub use crate::context::Context;9 pub use crate::error::{Error, Errors};10 11 /// `Result<T, Error>`22 unmodified lines