Skip to content

Commit

Permalink
Rewrite BinaryInteger+Addition.swift tests (#108) (#110).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Oct 18, 2024
1 parent 1b3d702 commit 3b63b62
Show file tree
Hide file tree
Showing 2 changed files with 274 additions and 129 deletions.
36 changes: 36 additions & 0 deletions Sources/TestKit2/Utilities+Reduce.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//=----------------------------------------------------------------------------=
// This source file is part of the Ultimathnum open source project.
//
// Copyright (c) 2023 Oscar Byström Ericsson
// Licensed under Apache License, Version 2.0
//
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
//=----------------------------------------------------------------------------=

//*============================================================================*
// MARK: * Utilities x Reduce
//*============================================================================*

@inlinable public func reduce<T>(
_ transform: (consuming T) throws -> T,
_ rhs: T
) rethrows -> T {
try transform(rhs)
}

@inlinable public func reduce<T>(
_ lhs: consuming T,
_ transform: (consuming T, borrowing T) throws -> T,
_ rhs: borrowing T
) rethrows -> T {
try transform(lhs, rhs)
}

@inlinable public func reduce<T>(
_ lhs: consuming T,
_ transform: (inout T, borrowing T) throws -> Void,
_ rhs: borrowing T
) rethrows -> T {
try transform(&lhs, rhs)
return lhs
}
Loading

0 comments on commit 3b63b62

Please sign in to comment.