@@ -126,29 +126,6 @@ pub fn champion() -> File {
126126 _ => None ,
127127 }
128128 }
129-
130- /// https://github.com/MingweiSamuel/Riven/issues/36
131- pub ( crate ) fn serialize_result<S >(
132- val: & Result <Self , std:: num:: TryFromIntError >,
133- serializer: S ,
134- ) -> Result <S :: Ok , S :: Error >
135- where
136- S : serde:: ser:: Serializer ,
137- {
138- use serde:: ser:: Serialize ;
139- val. unwrap_or( Champion ( -1 ) ) . serialize( serializer)
140- }
141-
142- /// https://github.com/MingweiSamuel/Riven/issues/36
143- pub ( crate ) fn deserialize_result<' de, D >(
144- deserializer: D ,
145- ) -> Result <Result <Self , std:: num:: TryFromIntError >, D :: Error >
146- where
147- D : serde:: de:: Deserializer <' de>,
148- {
149- use std:: convert:: TryInto ;
150- <i64 as serde:: de:: Deserialize >:: deserialize( deserializer) . map( |id| id. try_into( ) . map( Self ) )
151- }
152129 }
153130 }
154131 } ;
@@ -158,14 +135,14 @@ pub fn champion() -> File {
158135 . iter ( )
159136 . flat_map ( |champion| {
160137 IntoIterator :: into_iter ( [ & champion. alias , & champion. name ] ) . flat_map ( move |s| {
138+ // e.g. `CHOG` for `Cho'Gath`.
161139 let chars_full = s. chars ( ) . filter ( |c| c. is_ascii_alphanumeric ( ) ) ;
140+ // e.g. `CHO` for `Cho'Gath`.
162141 let chars_first = s. chars ( ) . take_while ( |c| c. is_ascii_alphanumeric ( ) ) ;
163- let chars_word = s. chars ( ) . take_while ( |c| c. is_ascii_alphabetic ( ) ) ;
164142
165143 IntoIterator :: into_iter ( [
166144 Box :: new ( chars_full) as Box < dyn Iterator < Item = char > > ,
167145 Box :: new ( chars_first) ,
168- Box :: new ( chars_word) ,
169146 ] )
170147 . map ( move |chars| {
171148 let str: String = chars
@@ -187,21 +164,6 @@ pub fn champion() -> File {
187164 } ) ;
188165
189166 quote ! {
190- /// The error used for failures in [`Champion`]'s
191- /// [`FromStr`](std::str::FromStr) implementation.
192- ///
193- /// Currently only internally stores the four characters used to parse the
194- /// champion, but may change in the future.
195- #[ derive( Debug ) ]
196- pub struct ParseChampionError ( [ char ; 4 ] ) ;
197- impl std:: fmt:: Display for ParseChampionError {
198- fn fmt( & self , f: & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
199- let s: String = self . 0 . iter( ) . copied( ) . take_while( |& c| '\0' != c) . collect( ) ;
200- write!( f, "Failed to parse unknown champion prefix: {:?}" , s)
201- }
202- }
203- impl std:: error:: Error for ParseChampionError { }
204-
205167 impl std:: str :: FromStr for Champion {
206168 type Err = ParseChampionError ;
207169 fn from_str( s: & str ) -> Result <Self , Self :: Err > {
@@ -218,13 +180,6 @@ pub fn champion() -> File {
218180 }
219181 }
220182 }
221-
222- impl std:: convert:: TryFrom <& str > for Champion {
223- type Error = <Self as std:: str :: FromStr >:: Err ;
224- fn try_from( value: & str ) -> Result <Self , Self :: Error > {
225- <Self as std:: str :: FromStr >:: from_str( value)
226- }
227- }
228183 }
229184 } ;
230185
0 commit comments