Add more from the std
This commit is contained in:
@@ -21,7 +21,7 @@ pub fn stdin() -> Stdin {
|
||||
Stdin
|
||||
}
|
||||
|
||||
pub type Result<T> = core::result::Result<T, ()>;
|
||||
pub type Result<T> = core::result::Result<T, Error>;
|
||||
|
||||
pub(super) struct Repr();
|
||||
|
||||
@@ -30,10 +30,42 @@ pub(super) struct Repr();
|
||||
#[unstable(feature = "io_const_error", issue = "133448")]
|
||||
#[allow_internal_unstable(hint_must_use, io_const_error_internals)]
|
||||
pub macro const_error($kind:expr, $message:expr $(,)?) {
|
||||
()
|
||||
crate::io::Error::new()
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Error {
|
||||
repr: Repr,
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub const fn new() -> Self {
|
||||
Self { repr: Repr() }
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Error {
|
||||
pub(crate) const INVALID_UTF8: Self =
|
||||
const_error!(ErrorKind::InvalidData, "stream did not contain valid UTF-8");
|
||||
|
||||
pub(crate) const READ_EXACT_EOF: Self =
|
||||
const_error!(ErrorKind::UnexpectedEof, "failed to fill whole buffer");
|
||||
|
||||
pub(crate) const UNKNOWN_THREAD_COUNT: Self = const_error!(
|
||||
ErrorKind::NotFound,
|
||||
"the number of hardware threads is not known for the target platform",
|
||||
);
|
||||
|
||||
pub(crate) const UNSUPPORTED_PLATFORM: Self =
|
||||
const_error!(ErrorKind::Unsupported, "operation not supported on this platform");
|
||||
|
||||
pub(crate) const WRITE_ALL_EOF: Self =
|
||||
const_error!(ErrorKind::WriteZero, "failed to write whole buffer");
|
||||
|
||||
pub(crate) const ZERO_TIMEOUT: Self =
|
||||
const_error!(ErrorKind::InvalidInput, "cannot set a 0 duration timeout");
|
||||
|
||||
pub(crate) const NO_ADDRESSES: Self =
|
||||
const_error!(ErrorKind::InvalidInput, "could not resolve to any addresses");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user