11use super :: error;
22use super :: ztxt;
33use super :: RawDmi ;
4- use image ;
4+
55use image:: imageops;
66use image:: GenericImageView ;
77use std:: collections:: HashMap ;
@@ -21,9 +21,7 @@ impl Icon {
2121 let chunk_ztxt = match & raw_dmi. chunk_ztxt {
2222 Some ( chunk) => chunk. clone ( ) ,
2323 None => {
24- return Err ( error:: DmiError :: Generic ( format ! (
25- "Error loading icon: no zTXt chunk found."
26- ) ) )
24+ return Err ( error:: DmiError :: Generic ( "Error loading icon: no zTXt chunk found." . to_string ( ) ) )
2725 }
2826 } ;
2927 let decompressed_text = chunk_ztxt. data . decode ( ) ?;
@@ -41,9 +39,7 @@ impl Icon {
4139 let current_line = match decompressed_text. next ( ) {
4240 Some ( thing) => thing,
4341 None => {
44- return Err ( error:: DmiError :: Generic ( format ! (
45- "Error loading icon: no version header found."
46- ) ) )
42+ return Err ( error:: DmiError :: Generic ( "Error loading icon: no version header found." . to_string ( ) ) )
4743 }
4844 } ;
4945 let split_version: Vec < & str > = current_line. split_terminator ( " = " ) . collect ( ) ;
@@ -58,9 +54,7 @@ impl Icon {
5854 let current_line = match decompressed_text. next ( ) {
5955 Some ( thing) => thing,
6056 None => {
61- return Err ( error:: DmiError :: Generic ( format ! (
62- "Error loading icon: no width found."
63- ) ) )
57+ return Err ( error:: DmiError :: Generic ( "Error loading icon: no width found." . to_string ( ) ) )
6458 }
6559 } ;
6660 let split_version: Vec < & str > = current_line. split_terminator ( " = " ) . collect ( ) ;
@@ -75,9 +69,7 @@ impl Icon {
7569 let current_line = match decompressed_text. next ( ) {
7670 Some ( thing) => thing,
7771 None => {
78- return Err ( error:: DmiError :: Generic ( format ! (
79- "Error loading icon: no height found."
80- ) ) )
72+ return Err ( error:: DmiError :: Generic ( "Error loading icon: no height found." . to_string ( ) ) )
8173 }
8274 } ;
8375 let split_version: Vec < & str > = current_line. split_terminator ( " = " ) . collect ( ) ;
@@ -118,9 +110,7 @@ impl Icon {
118110 let mut current_line = match decompressed_text. next ( ) {
119111 Some ( thing) => thing,
120112 None => {
121- return Err ( error:: DmiError :: Generic ( format ! (
122- "Error loading icon: no DMI trailer nor states found."
123- ) ) )
113+ return Err ( error:: DmiError :: Generic ( "Error loading icon: no DMI trailer nor states found." . to_string ( ) ) )
124114 }
125115 } ;
126116
@@ -151,7 +141,7 @@ impl Icon {
151141 ) ) )
152142 }
153143 2 => String :: new ( ) , //Only the quotes, empty name otherwise.
154- length @ _ => String :: from_utf8 ( name[ 1 ..( length - 1 ) ] . to_vec ( ) ) ?, //Hacky way to trim. Blame the cool methods being nightly experimental.
144+ length => String :: from_utf8 ( name[ 1 ..( length - 1 ) ] . to_vec ( ) ) ?, //Hacky way to trim. Blame the cool methods being nightly experimental.
155145 } ;
156146
157147 let mut dirs = None ;
@@ -167,9 +157,7 @@ impl Icon {
167157 current_line = match decompressed_text. next ( ) {
168158 Some ( thing) => thing,
169159 None => {
170- return Err ( error:: DmiError :: Generic ( format ! (
171- "Error loading icon: no DMI trailer found."
172- ) ) )
160+ return Err ( error:: DmiError :: Generic ( "Error loading icon: no DMI trailer found." . to_string ( ) ) )
173161 }
174162 } ;
175163
@@ -189,7 +177,7 @@ impl Icon {
189177 "\t frames" => frames = Some ( split_version[ 1 ] . parse :: < u32 > ( ) ?) ,
190178 "\t delay" => {
191179 let mut delay_vector = vec ! [ ] ;
192- let text_delays = split_version[ 1 ] . split_terminator ( "," ) ;
180+ let text_delays = split_version[ 1 ] . split_terminator ( ',' ) ;
193181 for text_entry in text_delays {
194182 delay_vector. push ( text_entry. parse :: < f32 > ( ) ?) ;
195183 }
@@ -199,7 +187,7 @@ impl Icon {
199187 "\t rewind" => rewind = Some ( split_version[ 1 ] . parse :: < u32 > ( ) ?) ,
200188 "\t movement" => movement = Some ( split_version[ 1 ] . parse :: < u32 > ( ) ?) ,
201189 "\t hotspot" => {
202- let text_coordinates: Vec < & str > = split_version[ 1 ] . split_terminator ( "," ) . collect ( ) ;
190+ let text_coordinates: Vec < & str > = split_version[ 1 ] . split_terminator ( ',' ) . collect ( ) ;
203191 if text_coordinates. len ( ) != 3 {
204192 return Err ( error:: DmiError :: Generic ( format ! (
205193 "Error loading icon: improper hotspot found: {:#?}" ,
@@ -362,7 +350,7 @@ impl Icon {
362350
363351 new_dmi. chunk_ztxt = Some ( new_ztxt) ;
364352
365- Ok ( new_dmi. save ( & mut writter) ? )
353+ new_dmi. save ( & mut writter)
366354 }
367355}
368356
0 commit comments