mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Inlineable: protocol interface only
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
/// - x: A value to compare.
|
||||
/// - y: Another value to compare.
|
||||
/// - Returns: The lesser of `x` and `y`. If `x` is equal to `y`, returns `x`.
|
||||
@inlinable
|
||||
@inlinable // protocol-only
|
||||
public func min<T : Comparable>(_ x: T, _ y: T) -> T {
|
||||
// In case `x == y` we pick `x`.
|
||||
// This preserves any pre-existing order in case `T` has identity,
|
||||
@@ -34,7 +34,7 @@ public func min<T : Comparable>(_ x: T, _ y: T) -> T {
|
||||
/// - rest: Zero or more additional values.
|
||||
/// - Returns: The least of all the arguments. If there are multiple equal
|
||||
/// least arguments, the result is the first one.
|
||||
@inlinable
|
||||
@inlinable // protocol-only
|
||||
public func min<T : Comparable>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T {
|
||||
var minValue = min(min(x, y), z)
|
||||
// In case `value == minValue`, we pick `minValue`. See min(_:_:).
|
||||
@@ -50,7 +50,7 @@ public func min<T : Comparable>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T {
|
||||
/// - x: A value to compare.
|
||||
/// - y: Another value to compare.
|
||||
/// - Returns: The greater of `x` and `y`. If `x` is equal to `y`, returns `y`.
|
||||
@inlinable
|
||||
@inlinable // protocol-only
|
||||
public func max<T : Comparable>(_ x: T, _ y: T) -> T {
|
||||
// In case `x == y`, we pick `y`. See min(_:_:).
|
||||
return y >= x ? y : x
|
||||
@@ -65,7 +65,7 @@ public func max<T : Comparable>(_ x: T, _ y: T) -> T {
|
||||
/// - rest: Zero or more additional values.
|
||||
/// - Returns: The greatest of all the arguments. If there are multiple equal
|
||||
/// greatest arguments, the result is the last one.
|
||||
@inlinable
|
||||
@inlinable // protocol-only
|
||||
public func max<T : Comparable>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T {
|
||||
var maxValue = max(max(x, y), z)
|
||||
// In case `value == maxValue`, we pick `value`. See min(_:_:).
|
||||
|
||||
Reference in New Issue
Block a user