Repo // +KeyValueStructs.
This commit is contained in:
parent
d06a39572e
commit
0dd4c01988
|
@ -0,0 +1,63 @@
|
|||
// Copyright (c) 2021 and onwards The vChewing Project (MIT-NTL License).
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
1. The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
2. No trademark license is granted to use the trade names, trademarks, service
|
||||
marks, or product names of Contributor, except as required to fulfill notice
|
||||
requirements above.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
extension vChewing {
|
||||
@frozen public struct KeyValue: Equatable {
|
||||
var key: String
|
||||
var value: String
|
||||
|
||||
public init(key: String = "", value: String = "") {
|
||||
self.key = key
|
||||
self.value = value
|
||||
}
|
||||
|
||||
public static func == (lhs: KeyValue, rhs: KeyValue) -> Bool {
|
||||
lhs.key == rhs.key && lhs.value == rhs.value
|
||||
}
|
||||
}
|
||||
|
||||
@frozen public struct KeyValueRate: Equatable {
|
||||
var key: String
|
||||
var value: String
|
||||
var rate: Double
|
||||
|
||||
public init(key: String = "", value: String = "", rate: Double = 0.0) {
|
||||
self.key = key
|
||||
self.value = value
|
||||
self.rate = rate
|
||||
}
|
||||
|
||||
public init(keyValue: KeyValue = KeyValue(key: "", value: ""), rate: Double = 0.0) {
|
||||
key = keyValue.key
|
||||
value = keyValue.value
|
||||
self.rate = rate
|
||||
}
|
||||
|
||||
public static func == (lhs: KeyValueRate, rhs: KeyValueRate) -> Bool {
|
||||
lhs.key == rhs.key && lhs.value == rhs.value && lhs.rate == rhs.rate
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue