Skip to content

gpt_disk_types: Unconditionally implement the Error trait #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gpt_disk_types/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

* MSRV increased to 1.81.
* The `Error` trait is now unconditionally implemented for all error types.

# 0.16.0

3 changes: 1 addition & 2 deletions gpt_disk_types/README.md
Original file line number Diff line number Diff line change
@@ -20,8 +20,7 @@ No features are enabled by default.
* `bytemuck`: Implements bytemuck's `Pod` and `Zeroable` traits for many
of the types in this crate. Also enables some methods that rely on
byte access.
* `std`: Provides `std::error::Error` implementations for all of the
error types.
* `std`: Currently has no effect.

## Minimum Supported Rust Version (MSRV)

7 changes: 2 additions & 5 deletions gpt_disk_types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -44,8 +44,7 @@
//! * `bytemuck`: Implements bytemuck's `Pod` and `Zeroable` traits for
//! many of the types in this crate. Also enables some methods that
//! rely on byte access.
//! * `std`: Provides `std::error::Error` implementations for all of the
//! error types. Off by default.
//! * `std`: Currently has no effect.
//!
//! # Examples
//!
@@ -85,7 +84,7 @@
//! };
//! ```
#![cfg_attr(not(feature = "std"), no_std)]
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(missing_copy_implementations)]
#![warn(missing_debug_implementations)]
@@ -107,8 +106,6 @@ mod mbr;
mod num;
mod partition_array;
mod partition_entry;
#[cfg(feature = "std")]
mod std_support;

// Re-export dependencies.
pub use crc;
2 changes: 2 additions & 0 deletions gpt_disk_types/src/partition_array.rs
Original file line number Diff line number Diff line change
@@ -145,6 +145,8 @@ impl Display for GptPartitionEntryArrayError {
}
}

impl core::error::Error for GptPartitionEntryArrayError {}

/// Storage for a GPT partition entry array.
#[allow(missing_debug_implementations)]
pub struct GptPartitionEntryArray<'a> {
21 changes: 6 additions & 15 deletions gpt_disk_types/src/partition_entry.rs
Original file line number Diff line number Diff line change
@@ -241,11 +241,6 @@ impl Iterator for GptPartitionNameCharIter<'_> {
}

/// Error type for [`GptPartitionName::set_char`].
///
/// If the `std` feature is enabled, this type implements the [`Error`]
/// trait.
///
/// [`Error`]: std::error::Error
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub enum GptPartitionNameSetCharError {
/// Character index is outside the range `0..36`.
@@ -266,6 +261,8 @@ impl Display for GptPartitionNameSetCharError {
}
}

impl core::error::Error for GptPartitionNameSetCharError {}

/// Human readable partition label encoded as a null-terminated UCS-2
/// string.
///
@@ -347,11 +344,6 @@ impl Default for GptPartitionName {
}

/// Error type for [`GptPartitionName::from_str`].
///
/// If the `std` feature is enabled, this type implements the [`Error`]
/// trait.
///
/// [`Error`]: std::error::Error
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub enum GptPartitionNameFromStrError {
/// Input string is too long.
@@ -379,6 +371,8 @@ impl From<ucs2::Error> for GptPartitionNameFromStrError {
}
}

impl core::error::Error for GptPartitionNameFromStrError {}

impl FromStr for GptPartitionName {
type Err = GptPartitionNameFromStrError;

@@ -466,11 +460,6 @@ impl Display for GptPartitionEntry {
}

/// Error returned by [`GptPartitionEntrySize::new`].
///
/// If the `std` feature is enabled, this type implements the [`Error`]
/// trait.
///
/// [`Error`]: std::error::Error
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct GptPartitionEntrySizeError;

@@ -480,6 +469,8 @@ impl Display for GptPartitionEntrySizeError {
}
}

impl core::error::Error for GptPartitionEntrySizeError {}

/// Size in bytes of entries in the partition entry array.
///
/// A valid partition entry size must be a value of 128×2ⁿ, where n is
21 changes: 0 additions & 21 deletions gpt_disk_types/src/std_support.rs

This file was deleted.