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 {
1919 lhs. description == rhs. description &&
2020 lhs. icon == rhs. icon
2121 }
22+
23+ static let Empty = Legend ( description: " " , icon: " " )
2224}
2325
2426extension Character {
@@ -38,20 +40,15 @@ extension Character {
3840
3941extension String {
4042 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
4545 }
4646
47- var description = self
48- var icon = " "
49-
5047 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) )
5350 }
5451
55- return Legend ( description: description , icon: icon )
52+ return Legend ( description: self , icon: " " )
5653 }
5754}
You can’t perform that action at this time.
0 commit comments