core::error
本頁內容
API 參考只有英文版,由標準函式庫原始碼中的英文文件註解產生。
Result<T, E>, an error kept as a value.
Errors travel through throws / try; Result is for
holding one (collected results, callbacks, caches): "throw it:
throws; keep it: Result". ? does not apply to it (T | none
only).
Ok / Err are bare names where a Result is expected (the
expected type picks the variant).
Structs
ParseErrorSource
pub struct ParseErrorA str that is not a valid value of the requested type
(thrown by str::parse / FromStr).
inputfailed at bytepositionbecause ofmessage.The text that did not parse.
The byte offset in
inputwhere parsing failed.Why it failed, without the input
Displayadds.
ValueErrorSource
pub struct ValueErrorAn invalid argument value (FormatSpec::parse,
hkdf::expand, ...).
An error saying
message.What went wrong, for display.
OverflowErrorSource
pub struct OverflowErrorA value out of a fixed-width type's range in a checked conversion
(thrown by try_from / try_into).
operation("try_from", ...) overflowed target typetype_name("i32", ...).The operation that overflowed:
"try_from", ...The target type:
"i32", ...What went wrong, for display.
ConversionErrorSource
pub struct ConversionErrorA failed TryFrom conversion: the trait's default Error
for impls that name no more specific one.
An error saying
message.What went wrong, for display.
TypeErrorSource
pub struct TypeErrorA value of the wrong type.
A mismatch:
expectedwas wanted,actualwas found.The type that was wanted.
The type that was found.
What went wrong, for display.
StackOverflowErrorSource
pub struct StackOverflowErrorFatal: the stack ran out. Never thrown; the runtime reports it and exits with 101.
What went wrong, for display.
OutOfMemoryErrorSource
pub struct OutOfMemoryErrorFatal: an allocation failed. Never thrown; the runtime reports it and exits with 101.
What went wrong, for display.
InternalErrorSource
pub struct InternalErrorFatal: a compiler bug reached at run time. Never thrown; the runtime reports it and exits with 101.
What went wrong, for display.
Enums
ResultSource
pub enum Result<T, E>A value or an error, kept as a value: Ok(T) or Err(E).
Run
f, keeping its value or its error.trueforOk.trueforErr.The value, or
nonewhenselfisErr.The error, or
nonewhenselfisOk.Back into the error flow: the value, or
throwthe error.The value; panics on
Err, showing the error.The value, or
defaultonErr.The value, or
fof the error onErr.fapplied to the value; anErrpasses through.fapplied to the error; anOkpasses through.fof the value onOk; anErrpasses through.fof the error onErr; anOkpasses through.
Traits
ErrorSource
pub trait Error: Display + DebugEvery error type's surface. Untyped throws
means throws (any Error).
The error that caused this one, if any.