Skip to content

Commit

Permalink
Implement Eq for NSValue
Browse files Browse the repository at this point in the history
Note that `NSNumber` already implements `Eq` since 3661935, which was
the biggest blocker for adding this implementation.
  • Loading branch information
madsmtm committed Aug 15, 2024
1 parent df631d1 commit 4a390f6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions crates/objc2/src/topics/about_generated/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* `objc2-foundation`: `MainThreadMarker::from` now debug-asserts that it is
actually running on the main thread.
* `objc2-foundation`: Added `NSData::to_vec` and `NSData::iter` helper methods.
* `objc2-foundation`: Added `Eq` implementation for `NSValue` and subclasses.

### Changed
* `objc2-foundation`: Allow using `MainThreadBound` without the `NSThread`
Expand Down
2 changes: 2 additions & 0 deletions framework-crates/objc2-foundation/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ impl PartialEq for NSValue {
}
}

impl Eq for NSValue {}

impl fmt::Debug for NSValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let enc = self.encoding().unwrap_or("(NULL)");
Expand Down
3 changes: 1 addition & 2 deletions framework-crates/objc2-foundation/translation-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ class.NSProcessInfo.derives = "PartialEq, Eq, Hash"
class.NSString.derives = "PartialEq, Eq, Hash"
class.NSUUID.derives = "PartialEq, Eq, Hash"

# Overridden because whether or not it is Eq depends on the inner value
# Overridden to use more performant implementation for `PartialEq`
class.NSValue.derives = ""
class.NSNumber.derives = ""
class.NSDecimalNumber.derives = "Debug, PartialEq, Hash"

# Returns `nil` on Apple and GNUStep throws an exception on all other messages
# to this invalid instance.
Expand Down
2 changes: 1 addition & 1 deletion generated

0 comments on commit 4a390f6

Please sign in to comment.