- Proposal: SE-NNNN
- Authors: Owen Voorhees
- Review Manager: TBD
- Status: Pitch
- Implementation: apple/swift#25997
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CustomLayout.swift | |
// LayoutKit | |
// | |
// Created by Owen Voorhees on 10/6/16. | |
// Copyright © 2016 Owen Voorhees. All rights reserved. | |
// | |
//Lays out children using a custom set of constraints | |
public class CustomLayout: Layout { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Equatable2 { | |
//@memberwiseDerivable(mapper: equatable2Mapper, reducer: equatable2Reducer, reduceInitialResult: true) | |
static func == (_: Self, _: Self) -> Bool | |
} | |
// lhs and rhs come from the derived requirement, memberKeyPath is added to the argument list | |
// the return type must match the reducer's argument types | |
// Self is replaced by generic parameter T, U is the type of the member (which conforms to the given protocol) | |
func equatable2Mapper<T, U: Equatable2>(_ lhs: T, _ rhs: T, memberKeyPath: KeyPath<T, U>) -> Bool { | |
return lhs[keyPath: memberKeyPath] == rhs[keyPath: memberKeyPath] |