Skip to content

Commit

Permalink
DefaultTo* structs derive Clone, Debug, etc. (#84)
Browse files Browse the repository at this point in the history
When using either `DefaultToHost` or `DefaultToUnknown` structs (which
are named tuples with `Default` implementations), the developer loses
the benefits of being able to use them in `Clone`, `Debug`, `PartialEq`,
`Eq`, and `Hash` contexts.

This commit adds the `#[derive]` macros to these structs to retain these
traits from `Triple`.
  • Loading branch information
thommahoney authored Feb 10, 2023
1 parent 050d581 commit 3a4fc54
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub use self::triple::{CallingConvention, Endianness, PointerWidth, Triple};

/// A simple wrapper around `Triple` that provides an implementation of
/// `Default` which defaults to `Triple::host()`.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DefaultToHost(pub Triple);

impl Default for DefaultToHost {
Expand All @@ -50,6 +51,7 @@ impl Default for DefaultToHost {

/// A simple wrapper around `Triple` that provides an implementation of
/// `Default` which defaults to `Triple::unknown()`.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DefaultToUnknown(pub Triple);

impl Default for DefaultToUnknown {
Expand Down

0 comments on commit 3a4fc54

Please sign in to comment.