Makes the SizeType initializer prefer proper case but fall back to case insensitive.
This commit is contained in:
@@ -27,4 +27,26 @@ enum SizeType: String, CaseIterable, Identifiable {
|
|||||||
case .gargantuan: return "gargantuan"
|
case .gargantuan: return "gargantuan"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init?(rawValue: String) {
|
||||||
|
var match: SizeType? = nil
|
||||||
|
|
||||||
|
for size in SizeType.allCases {
|
||||||
|
if (size.rawValue == rawValue) {
|
||||||
|
match = size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for size in SizeType.allCases {
|
||||||
|
if (size.rawValue.lowercased() == rawValue.lowercased()) {
|
||||||
|
match = size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match == nil) {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
self = match!
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user