@@ -2,6 +2,8 @@ use std::fmt;
2
2
use std:: pin:: Pin ;
3
3
use std:: ptr:: NonNull ;
4
4
5
+ use uncased:: { Uncased , UncasedStr } ;
6
+
5
7
#[ cfg( test) ]
6
8
mod test;
7
9
@@ -36,10 +38,10 @@ impl fmt::Debug for Mailmap {
36
38
37
39
#[ derive( Copy , Clone ) ]
38
40
struct RawMapEntry {
39
- canonical_name : Option < NonNull < str > > ,
40
- canonical_email : Option < NonNull < str > > ,
41
- current_name : Option < NonNull < str > > ,
42
- current_email : Option < NonNull < str > > ,
41
+ canonical_name : Option < NonNull < UncasedStr > > ,
42
+ canonical_email : Option < NonNull < UncasedStr > > ,
43
+ current_name : Option < NonNull < UncasedStr > > ,
44
+ current_email : Option < NonNull < UncasedStr > > ,
43
45
}
44
46
45
47
impl RawMapEntry {
@@ -55,10 +57,10 @@ impl RawMapEntry {
55
57
56
58
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
57
59
struct MapEntry < ' a > {
58
- canonical_name : Option < & ' a str > ,
59
- canonical_email : Option < & ' a str > ,
60
- current_name : Option < & ' a str > ,
61
- current_email : Option < & ' a str > ,
60
+ canonical_name : Option < & ' a UncasedStr > ,
61
+ canonical_email : Option < & ' a UncasedStr > ,
62
+ current_name : Option < & ' a UncasedStr > ,
63
+ current_email : Option < & ' a UncasedStr > ,
62
64
}
63
65
64
66
impl < ' a > MapEntry < ' a > {
@@ -74,8 +76,8 @@ impl<'a> MapEntry<'a> {
74
76
75
77
#[ derive( Clone , PartialEq , PartialOrd , Ord , Eq , Hash ) ]
76
78
pub struct Author {
77
- pub name : String ,
78
- pub email : String ,
79
+ pub name : Uncased < ' static > ,
80
+ pub email : Uncased < ' static > ,
79
81
}
80
82
81
83
impl fmt:: Debug for Author {
@@ -107,15 +109,31 @@ impl Mailmap {
107
109
if let Some ( name) = entry. current_name {
108
110
if author. name == name && author. email == email {
109
111
return Author {
110
- name : entry. canonical_name . unwrap_or ( & author. name ) . to_owned ( ) ,
111
- email : entry. canonical_email . expect ( "canonical email" ) . to_owned ( ) ,
112
+ name : entry
113
+ . canonical_name
114
+ . unwrap_or ( & author. name )
115
+ . to_string ( )
116
+ . into ( ) ,
117
+ email : entry
118
+ . canonical_email
119
+ . expect ( "canonical email" )
120
+ . to_string ( )
121
+ . into ( ) ,
112
122
} ;
113
123
}
114
124
} else {
115
125
if author. email == email {
116
126
return Author {
117
- name : entry. canonical_name . unwrap_or ( & author. name ) . to_owned ( ) ,
118
- email : entry. canonical_email . expect ( "canonical email" ) . to_owned ( ) ,
127
+ name : entry
128
+ . canonical_name
129
+ . unwrap_or ( & author. name )
130
+ . to_string ( )
131
+ . into ( ) ,
132
+ email : entry
133
+ . canonical_email
134
+ . expect ( "canonical email" )
135
+ . to_string ( )
136
+ . into ( ) ,
119
137
} ;
120
138
}
121
139
}
@@ -126,7 +144,7 @@ impl Mailmap {
126
144
}
127
145
}
128
146
129
- fn read_email < ' a > ( line : & mut & ' a str ) -> Option < & ' a str > {
147
+ fn read_email < ' a > ( line : & mut & ' a str ) -> Option < & ' a UncasedStr > {
130
148
if !line. starts_with ( '<' ) {
131
149
return None ;
132
150
}
@@ -136,21 +154,21 @@ fn read_email<'a>(line: &mut &'a str) -> Option<&'a str> {
136
154
. unwrap_or_else ( || panic ! ( "could not find email end in {:?}" , line) ) ;
137
155
let ret = & line[ 1 ..end] ;
138
156
* line = & line[ end + 1 ..] ;
139
- Some ( ret)
157
+ Some ( ret. into ( ) )
140
158
}
141
159
142
- fn read_name < ' a > ( line : & mut & ' a str ) -> Option < & ' a str > {
160
+ fn read_name < ' a > ( line : & mut & ' a str ) -> Option < & ' a UncasedStr > {
143
161
let end = if let Some ( end) = line. find ( '<' ) {
144
162
end
145
163
} else {
146
164
return None ;
147
165
} ;
148
- let ret = & line[ ..end] . trim ( ) ;
166
+ let ret = line[ ..end] . trim ( ) ;
149
167
* line = & line[ end..] ;
150
168
if ret. is_empty ( ) {
151
169
None
152
170
} else {
153
- Some ( ret)
171
+ Some ( ret. into ( ) )
154
172
}
155
173
}
156
174
0 commit comments