我试图让这段代码正常工作
{ (tableview, originalItems, item, indexPath) in
guard let matchingItem = originalItems.filter({ matching($0, with: item.itemIdentifier) }).first else {
LogManager.Fatal.log("No item matching identifier : \(item.itemIdentifier)")
return nil
}
Some code
}
originalItems
是[Any]
,我的功能是
static func matching<T: SectionRowRepresentable>(_ item: T, with identifier: String) -> Bool where T.Identity == AnyItemRepresentable.Identity
如何从T
推断Any
知道SectionRowRepresentable
具有关联类型Identity
public protocol SectionRowRepresentable: Equatable {
associatedtype Identity: Hashable
var itemIdentifier: String { get }
}