-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Declare some FloatingPointSign members explicitly for @inlinable #16043
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1225,6 +1225,31 @@ public enum FloatingPointSign: Int { | |
|
||
/// The sign for a negative value. | ||
case minus | ||
|
||
// Explicit declarations of otherwise-synthesized members to make them | ||
// @inlinable, promising that we will never change the implementation. | ||
|
||
@inlinable | ||
public init?(rawValue: Int) { | ||
switch rawValue { | ||
case 0: self = .plus | ||
case 1: self = .minus | ||
default: return nil | ||
} | ||
} | ||
|
||
@inlinable | ||
public var rawValue: Int { | ||
switch self { | ||
case .plus: return 0 | ||
case .minus: return 1 | ||
} | ||
} | ||
|
||
@inlinable | ||
public static func ==(a: FloatingPointSign, b: FloatingPointSign) -> Bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have a default == witness for RawRepresentable things somewhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably do, but a client isn't supposed to inline that when using it on someone else's type. |
||
return a.rawValue == b.rawValue | ||
} | ||
} | ||
|
||
/// The IEEE 754 floating-point classes. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we synthesize @inlinable members for any frozen RawRepresentable enum?