@@ -131,11 +131,8 @@ pub enum Attribute {
131
131
StrikeThrough = 8 ,
132
132
}
133
133
134
- #[ derive( Clone , Copy , PartialEq , Eq ) ]
135
- struct Attributes ( u16 ) ;
136
-
137
- impl Attributes {
138
- const ATTRIBUTES_LOOKUP : [ Attribute ; 9 ] = [
134
+ impl Attribute {
135
+ const MAP : [ Attribute ; 9 ] = [
139
136
Attribute :: Bold ,
140
137
Attribute :: Dim ,
141
138
Attribute :: Italic ,
@@ -146,10 +143,15 @@ impl Attributes {
146
143
Attribute :: Hidden ,
147
144
Attribute :: StrikeThrough ,
148
145
] ;
146
+ }
149
147
148
+ #[ derive( Clone , Copy , PartialEq , Eq ) ]
149
+ struct Attributes ( u16 ) ;
150
+
151
+ impl Attributes {
150
152
#[ inline]
151
153
const fn new ( ) -> Self {
152
- Attributes ( 0 )
154
+ Self ( 0 )
153
155
}
154
156
155
157
#[ inline]
@@ -173,7 +175,7 @@ impl Attributes {
173
175
174
176
#[ inline]
175
177
fn attrs ( self ) -> impl Iterator < Item = Attribute > {
176
- self . bits ( ) . map ( |bit| Self :: ATTRIBUTES_LOOKUP [ bit as usize ] )
178
+ self . bits ( ) . map ( |bit| Attribute :: MAP [ bit as usize ] )
177
179
}
178
180
}
179
181
@@ -1021,7 +1023,7 @@ fn test_pad_str_with() {
1021
1023
1022
1024
#[ test]
1023
1025
fn test_attributes_single ( ) {
1024
- for attr in Attributes :: ATTRIBUTES_LOOKUP {
1026
+ for attr in Attribute :: MAP {
1025
1027
let attrs = Attributes :: new ( ) . insert ( attr) ;
1026
1028
assert_eq ! ( attrs. bits( ) . collect:: <Vec <_>>( ) , [ attr as u16 ] ) ;
1027
1029
assert_eq ! ( attrs. ansi_nums( ) . collect:: <Vec <_>>( ) , [ attr as u16 + 1 ] ) ;
@@ -1046,7 +1048,7 @@ fn test_attributes_many() {
1046
1048
Attribute :: Reverse ,
1047
1049
Attribute :: StrikeThrough ,
1048
1050
] ,
1049
- & Attributes :: ATTRIBUTES_LOOKUP ,
1051
+ & Attribute :: MAP ,
1050
1052
] ;
1051
1053
for test_attrs in tests {
1052
1054
let mut attrs = Attributes :: new ( ) ;
0 commit comments