由于大端和小端与字节顺序有关,并且由于一个u8
是一个字节,所以不会u8::from_be_bytes
并且u8::from_le_bytes
总是具有相同的行为吗?
我注意到 Rust软弃用了Error::description
. 建议使用Display
或to_string()
获取我的错误描述,但这是否意味着我必须重新编写当前的错误消息系统来处理String
而不是&str
?
我正在使用此代码,并且我注意到野外的代码看起来很相似:
fn description(&self) -> &str {
match *self {
Error::CannotDeriveFromHardenedKey => "cannot derive hardened key from public key",
Error::Ecdsa(ref e) => error::Error::description(e),
Error::RngError(_) => "rng error",
Error::MnemonicError(_) => "mnemonic error",
}
}
Run Code Online (Sandbox Code Playgroud)