Fix witness_version leaf error type

Leaf error types should typically have private fields, provide accessor
functions, and not use `non_exhaustive`.
This commit is contained in:
Tobin C. Harding 2024-03-01 17:04:10 +11:00
parent 2af764e859
commit 43c5eb765c
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 7 additions and 5 deletions

View File

@ -245,10 +245,14 @@ impl From<TryFromError> for TryFromInstructionError {
/// Error attempting to create a [`WitnessVersion`] from an integer.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct TryFromError {
/// The invalid non-witness version integer.
pub invalid: u8,
invalid: u8,
}
impl TryFromError {
/// Returns the invalid non-witness version integer.
pub fn invalid_version(&self) -> u8 { self.invalid }
}
impl fmt::Display for TryFromError {
@ -258,6 +262,4 @@ impl fmt::Display for TryFromError {
}
#[cfg(feature = "std")]
impl std::error::Error for TryFromError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
}
impl std::error::Error for TryFromError {}