File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ struct Legend: Codable, Equatable {
19
19
lhs. description == rhs. description &&
20
20
lhs. icon == rhs. icon
21
21
}
22
+
23
+ static let Empty = Legend ( description: " " , icon: " " )
22
24
}
23
25
24
26
extension Character {
@@ -38,20 +40,15 @@ extension Character {
38
40
39
41
extension String {
40
42
func asLegend( ) -> Legend {
41
- let chars = Array ( self )
42
-
43
- guard let firstChar = chars. first else {
44
- return Legend ( description: " " , icon: " " )
43
+ guard let firstChar = first else {
44
+ return Legend . Empty
45
45
}
46
46
47
- var description = self
48
- var icon = " "
49
-
50
47
if firstChar. isEmoji {
51
- description = String ( chars . dropFirst ( ) ) . trimmingCharacters ( in: . whitespacesAndNewlines)
52
- icon = String ( firstChar)
48
+ let description = String ( dropFirst ( ) ) . trimmingCharacters ( in: . whitespacesAndNewlines)
49
+ return Legend ( description : description , icon : String ( firstChar) )
53
50
}
54
51
55
- return Legend ( description: description , icon: icon )
52
+ return Legend ( description: self , icon: " " )
56
53
}
57
54
}
You can’t perform that action at this time.
0 commit comments