@@ -2,6 +2,8 @@ use std::fmt;
22use std:: pin:: Pin ;
33use std:: ptr:: NonNull ;
44
5+ use uncased:: { Uncased , UncasedStr } ;
6+
57#[ cfg( test) ]
68mod test;
79
@@ -36,10 +38,10 @@ impl fmt::Debug for Mailmap {
3638
3739#[ derive( Copy , Clone ) ]
3840struct 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 > > ,
4345}
4446
4547impl RawMapEntry {
@@ -55,10 +57,10 @@ impl RawMapEntry {
5557
5658#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
5759struct 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 > ,
6264}
6365
6466impl < ' a > MapEntry < ' a > {
@@ -74,8 +76,8 @@ impl<'a> MapEntry<'a> {
7476
7577#[ derive( Clone , PartialEq , PartialOrd , Ord , Eq , Hash ) ]
7678pub struct Author {
77- pub name : String ,
78- pub email : String ,
79+ pub name : Uncased < ' static > ,
80+ pub email : Uncased < ' static > ,
7981}
8082
8183impl fmt:: Debug for Author {
@@ -107,15 +109,31 @@ impl Mailmap {
107109 if let Some ( name) = entry. current_name {
108110 if author. name == name && author. email == email {
109111 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 ( ) ,
112122 } ;
113123 }
114124 } else {
115125 if author. email == email {
116126 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 ( ) ,
119137 } ;
120138 }
121139 }
@@ -126,7 +144,7 @@ impl Mailmap {
126144 }
127145}
128146
129- fn read_email < ' a > ( line : & mut & ' a str ) -> Option < & ' a str > {
147+ fn read_email < ' a > ( line : & mut & ' a str ) -> Option < & ' a UncasedStr > {
130148 if !line. starts_with ( '<' ) {
131149 return None ;
132150 }
@@ -136,21 +154,21 @@ fn read_email<'a>(line: &mut &'a str) -> Option<&'a str> {
136154 . unwrap_or_else ( || panic ! ( "could not find email end in {:?}" , line) ) ;
137155 let ret = & line[ 1 ..end] ;
138156 * line = & line[ end + 1 ..] ;
139- Some ( ret)
157+ Some ( ret. into ( ) )
140158}
141159
142- fn read_name < ' a > ( line : & mut & ' a str ) -> Option < & ' a str > {
160+ fn read_name < ' a > ( line : & mut & ' a str ) -> Option < & ' a UncasedStr > {
143161 let end = if let Some ( end) = line. find ( '<' ) {
144162 end
145163 } else {
146164 return None ;
147165 } ;
148- let ret = & line[ ..end] . trim ( ) ;
166+ let ret = line[ ..end] . trim ( ) ;
149167 * line = & line[ end..] ;
150168 if ret. is_empty ( ) {
151169 None
152170 } else {
153- Some ( ret)
171+ Some ( ret. into ( ) )
154172 }
155173}
156174
0 commit comments