@@ -3,7 +3,7 @@ use std::hash::Hash;
3
3
use std:: pin:: Pin ;
4
4
use std:: ptr:: NonNull ;
5
5
6
- use unicase :: UniCase ;
6
+ use uncased :: { Uncased , UncasedStr } ;
7
7
8
8
#[ cfg( test) ]
9
9
mod test;
@@ -39,10 +39,10 @@ impl fmt::Debug for Mailmap {
39
39
40
40
#[ derive( Copy , Clone ) ]
41
41
struct RawMapEntry {
42
- canonical_name : Option < NonNull < str > > ,
43
- canonical_email : Option < NonNull < str > > ,
44
- current_name : Option < NonNull < str > > ,
45
- current_email : Option < NonNull < str > > ,
42
+ canonical_name : Option < NonNull < UncasedStr > > ,
43
+ canonical_email : Option < NonNull < UncasedStr > > ,
44
+ current_name : Option < NonNull < UncasedStr > > ,
45
+ current_email : Option < NonNull < UncasedStr > > ,
46
46
}
47
47
48
48
impl RawMapEntry {
@@ -58,10 +58,10 @@ impl RawMapEntry {
58
58
59
59
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
60
60
struct MapEntry < ' a > {
61
- canonical_name : Option < & ' a str > ,
62
- canonical_email : Option < & ' a str > ,
63
- current_name : Option < & ' a str > ,
64
- current_email : Option < & ' a str > ,
61
+ canonical_name : Option < & ' a UncasedStr > ,
62
+ canonical_email : Option < & ' a UncasedStr > ,
63
+ current_name : Option < & ' a UncasedStr > ,
64
+ current_email : Option < & ' a UncasedStr > ,
65
65
}
66
66
67
67
impl < ' a > MapEntry < ' a > {
@@ -77,15 +77,15 @@ impl<'a> MapEntry<'a> {
77
77
78
78
#[ derive( Clone , PartialEq , PartialOrd , Ord , Eq , Hash ) ]
79
79
pub struct Author {
80
- pub name : UniCase < String > ,
81
- pub email : UniCase < String > ,
80
+ pub name : Uncased < ' static > ,
81
+ pub email : Uncased < ' static > ,
82
82
}
83
83
84
84
impl Author {
85
85
pub fn new ( name : String , email : String ) -> Self {
86
86
Self {
87
- name : UniCase :: new ( name) ,
88
- email : UniCase :: new ( email) ,
87
+ name : name. into ( ) ,
88
+ email : email. into ( ) ,
89
89
}
90
90
}
91
91
}
@@ -117,17 +117,17 @@ impl Mailmap {
117
117
let entry = unsafe { entry. to_entry ( & self . buffer ) } ;
118
118
if let Some ( email) = entry. current_email {
119
119
if let Some ( name) = entry. current_name {
120
- if author. name == UniCase :: new ( name) && author. email == UniCase :: new ( email) {
120
+ if author. name == name && author. email == email {
121
121
return Author :: new (
122
- entry. canonical_name . unwrap_or ( & author. name ) . to_owned ( ) ,
123
- entry. canonical_email . expect ( "canonical email" ) . to_owned ( ) ,
122
+ entry. canonical_name . unwrap_or ( & author. name ) . to_string ( ) ,
123
+ entry. canonical_email . expect ( "canonical email" ) . to_string ( ) ,
124
124
) ;
125
125
}
126
126
} else {
127
- if author. email == UniCase :: new ( email) {
127
+ if author. email == email {
128
128
return Author :: new (
129
- entry. canonical_name . unwrap_or ( & author. name ) . to_owned ( ) ,
130
- entry. canonical_email . expect ( "canonical email" ) . to_owned ( ) ,
129
+ entry. canonical_name . unwrap_or ( & author. name ) . to_string ( ) ,
130
+ entry. canonical_email . expect ( "canonical email" ) . to_string ( ) ,
131
131
) ;
132
132
}
133
133
}
@@ -138,7 +138,7 @@ impl Mailmap {
138
138
}
139
139
}
140
140
141
- fn read_email < ' a > ( line : & mut & ' a str ) -> Option < & ' a str > {
141
+ fn read_email < ' a > ( line : & mut & ' a str ) -> Option < & ' a UncasedStr > {
142
142
if !line. starts_with ( '<' ) {
143
143
return None ;
144
144
}
@@ -148,21 +148,21 @@ fn read_email<'a>(line: &mut &'a str) -> Option<&'a str> {
148
148
. unwrap_or_else ( || panic ! ( "could not find email end in {:?}" , line) ) ;
149
149
let ret = & line[ 1 ..end] ;
150
150
* line = & line[ end + 1 ..] ;
151
- Some ( ret)
151
+ Some ( ret. into ( ) )
152
152
}
153
153
154
- fn read_name < ' a > ( line : & mut & ' a str ) -> Option < & ' a str > {
154
+ fn read_name < ' a > ( line : & mut & ' a str ) -> Option < & ' a UncasedStr > {
155
155
let end = if let Some ( end) = line. find ( '<' ) {
156
156
end
157
157
} else {
158
158
return None ;
159
159
} ;
160
- let ret = & line[ ..end] . trim ( ) ;
160
+ let ret = line[ ..end] . trim ( ) ;
161
161
* line = & line[ end..] ;
162
162
if ret. is_empty ( ) {
163
163
None
164
164
} else {
165
- Some ( ret)
165
+ Some ( ret. into ( ) )
166
166
}
167
167
}
168
168
0 commit comments