Extend String methods to Substring

This commit is contained in:
Adam Fowler
2021-03-15 11:07:08 +00:00
parent adb3401398
commit e0a0b3fe8e

View File

@@ -3,9 +3,11 @@ protocol HBMustacheMethods {
func runMethod(_ name: String) -> Any? func runMethod(_ name: String) -> Any?
} }
extension String: HBMustacheMethods { extension StringProtocol {
func runMethod(_ name: String) -> Any? { func runMethod(_ name: String) -> Any? {
switch name { switch name {
case "capitalized":
return self.capitalized
case "lowercased": case "lowercased":
return self.lowercased() return self.lowercased()
case "uppercased": case "uppercased":
@@ -18,6 +20,9 @@ extension String: HBMustacheMethods {
} }
} }
extension String: HBMustacheMethods {}
extension Substring: HBMustacheMethods {}
protocol HBComparableSequence { protocol HBComparableSequence {
func runComparableMethod(_ name: String) -> Any? func runComparableMethod(_ name: String) -> Any?
} }