Inlineable: protocol interface only

This commit is contained in:
Ben Cohen
2018-06-20 15:42:46 -07:00
committed by Ben Cohen
parent f1cba8966f
commit c6b41a5ae5
14 changed files with 50 additions and 50 deletions

View File

@@ -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(_:_:).