From ae7f30e92275c91c7f489bb7f48e4b1d2d8b180f Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 2 Oct 2015 16:50:59 -0400 Subject: [PATCH] Parameterized Patch hashing. --- prototype/Doubt/Patch.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/prototype/Doubt/Patch.swift b/prototype/Doubt/Patch.swift index bce5a48b8..dc5d13083 100644 --- a/prototype/Doubt/Patch.swift +++ b/prototype/Doubt/Patch.swift @@ -19,3 +19,15 @@ extension Patch { && Optional.equals(Fix.equals(param))(left.state.after, right.state.after) } } + + +// MARK: - Hashing + +extension Patch { + public func hash(param: A -> Hash) -> Hash { + return Hash.Ordered([ + state.before.map { $0.hash(param) } ?? Hash.Empty, + state.after.map { $0.hash(param) } ?? Hash.Empty + ]) + } +}