core-error-0.0.0/.gitignore010064400017500001750000000000361354711362000140000ustar0000000000000000/target **/*.rs.bk Cargo.lock core-error-0.0.0/Cargo.toml.orig010064400017500001750000000004601354712273700147110ustar0000000000000000[package] name = "core-error" description = "std::error::Error for libcore" readme = "README.md" license = "MIT OR Apache-2.0" version = "0.0.0" authors = ["roblabla "] build = "build.rs" [build-dependencies] version_check = "0.9" [features] default = ["std"] alloc = [] std = [] core-error-0.0.0/Cargo.toml0000644000000015040000000000000111450ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "core-error" version = "0.0.0" authors = ["roblabla "] build = "build.rs" description = "std::error::Error for libcore" readme = "README.md" license = "MIT OR Apache-2.0" [build-dependencies.version_check] version = "0.9" [features] alloc = [] default = ["std"] std = [] core-error-0.0.0/README.md010064400017500001750000000027051354712200100132650ustar0000000000000000# Core Error With the recent proliferation of error-handling crates, it has become clear that the situation around the lack of a `core::error::Error` is really suboptimal. In `snafu`, `no_std` support is being introduced through a whole new Error trait just for `no_std` - which could lead to similar problems that `failure` had by becoming incompatible with the ecosystem. Ideally, the `Error` trait would show up in core, but due to coherence concerns and std-dependent features being added to `std::error::Error`, a resolution is unlikely to happen soon. As such, I propose making a new crate, `core-error` - exposing our own version of the `Error `trait. The goal of this crate is twofolds: - Provide a common trait for various error handling crates (Failure, Snafu, Fehler, Anyhow, error_chain, and any others?) - Allow no_std libraries that don't want to depend on a specific error handling crate to still expose errors that can interoperate with those libraries. This crate is still in the early stages. Once it reaches 1.0.0, it will be ready for integration in the various error crates. Furthermore, once it reaches 1.0.0, it will follow the same stability guarantees Rust does. # Minimum Rust Version This crate works all the way down to 1.0.0. It auto-detects the Rust version in order to know which error structs to implement the trait on. With `no-default-features`, the crate only compiles from 1.6.0 onwards (version at which `no_std` became stable).core-error-0.0.0/build.rs010064400017500001750000000005111354711001200134430ustar0000000000000000extern crate version_check; fn main() { let (version, _channel, _date) = version_check::triple().expect("Rustc to give us its version"); for i in 0..65536 { if version.at_least(&format!("1.{}.0", i)) { println!("cargo:rustc-cfg=rustc_1_{}_0", i) } else { break; } } }core-error-0.0.0/src/error_trait.rs010064400017500001750000000042021354711341400155010ustar0000000000000000use core::fmt::{Debug, Display}; /// `Error` is a trait representing the basic expectations for error values, /// i.e., values of type `E` in [`Result`]. Errors must describe /// themselves through the [`Display`] and [`Debug`] traits, and may provide /// cause chain information: /// /// The [`source`] method is generally used when errors cross "abstraction /// boundaries". If one module must report an error that is caused by an error /// from a lower-level module, it can allow access to that error via the /// [`source`] method. This makes it possible for the high-level module to /// provide its own errors while also revealing some of the implementation for /// debugging via [`source`] chains. /// /// [`Result`]: ../result/enum.Result.html /// [`Display`]: ../fmt/trait.Display.html /// [`Debug`]: ../fmt/trait.Debug.html /// [`source`]: trait.Error.html#method.source pub trait Error: Debug + Display { fn description(&self) -> &str { "description() is deprecated; use Display" } fn cause(&self) -> Option<&Error> { self.source() } fn source(&self) -> Option<&(Error + 'static)> { None } } macro_rules! impl_error { ($( #[$version:meta] $ty:path),*) => { $( #[$version] impl Error for $ty { } )* }; } // All errors supported by our minimum suported Rust version can be supported by // default. impl_error! { #[cfg(rustc_1_0_0)] ::core::str::ParseBoolError, #[cfg(rustc_1_0_0)] ::core::str::Utf8Error, #[cfg(rustc_1_0_0)] ::core::num::ParseIntError, #[cfg(rustc_1_0_0)] ::core::num::ParseFloatError, #[cfg(rustc_1_11_0)] ::core::fmt::Error, #[cfg(rustc_1_13_0)] ::core::cell::BorrowMutError, #[cfg(rustc_1_13_0)] ::core::cell::BorrowError, #[cfg(rustc_1_20_0)] ::core::char::ParseCharError, // Added in 1.27.0 in libcore. Added in 1.9.0 in libstd. // Rust is full of lies. #[cfg(rustc_1_27_0)] ::core::char::DecodeUtf16Error, #[cfg(rustc_1_34_0)] ::core::num::TryFromIntError, #[cfg(rustc_1_34_0)] ::core::array::TryFromSliceError, #[cfg(rustc_1_34_0)] ::core::char::CharTryFromError }core-error-0.0.0/src/lib.rs010064400017500001750000000007261354711171700137260ustar0000000000000000//! Traits for working with Errors. //! //! # Usage //! //! If you're a library, you should reexport *all the features* exposed by this //! crate. // If std feature is disabled, this crate is no_std. // This avoids making this crate fail on std build in version 1.5.0 and under #![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "std")] pub use std::error::*; #[cfg(not(feature = "std"))] mod error_trait; #[cfg(not(feature = "std"))] pub use error_trait::*;core-error-0.0.0/.cargo_vcs_info.json0000644000000001120000000000000131410ustar00{ "git": { "sha1": "b78dd3c70f4b6c345c997f19597836f1482e064a" } }