Add more from the std

This commit is contained in:
2026-03-17 21:33:34 +01:00
parent 56ad115e58
commit 9958b23c89
32 changed files with 10515 additions and 6 deletions

View File

@@ -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");
}