mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Diffs have a magnitude.
This commit is contained in:
parent
e823f84d4a
commit
0dfd3a5ecd
@ -28,6 +28,17 @@ public enum Diff: CustomDebugStringConvertible, CustomDocConvertible, Equatable
|
||||
}
|
||||
}
|
||||
|
||||
public var magnitude: Int {
|
||||
switch self {
|
||||
case .Empty:
|
||||
return 0
|
||||
case .Patch:
|
||||
return 1
|
||||
case let .Copy(s):
|
||||
return s.map { $0.magnitude }.reduce(0, combine: +)
|
||||
}
|
||||
}
|
||||
|
||||
public init(_ a: Fix, _ b: Fix) {
|
||||
switch (a, b) {
|
||||
case (.Empty, .Empty):
|
||||
|
Loading…
Reference in New Issue
Block a user