|
1 | 1 | use std::fmt; |
| 2 | +use std::fmt::Write; |
2 | 3 | use std::str::FromStr; |
3 | 4 | use xsd_macro_utils::UtilsDefaultSerde; |
4 | 5 |
|
@@ -166,7 +167,7 @@ impl FromStr for Duration { |
166 | 167 | context.is_dot_found = true; |
167 | 168 | } |
168 | 169 | digit => { |
169 | | - if !digit.is_digit(10) { |
| 170 | + if !digit.is_ascii_digit() { |
170 | 171 | return Err("Incorrect character occurred".into()); |
171 | 172 | } |
172 | 173 |
|
@@ -215,24 +216,24 @@ impl fmt::Display for Duration { |
215 | 216 |
|
216 | 217 | let mut date_str = String::new(); |
217 | 218 | if self.years > 0 { |
218 | | - date_str.push_str(&format!("{}Y", self.years)); |
| 219 | + write!(&mut date_str, "{}Y", self.years)?; |
219 | 220 | } |
220 | 221 | if self.months > 0 { |
221 | | - date_str.push_str(&format!("{}M", self.months)); |
| 222 | + write!(&mut date_str, "{}M", self.months)?; |
222 | 223 | } |
223 | 224 | if self.days > 0 { |
224 | | - date_str.push_str(&format!("{}D", self.days)); |
| 225 | + write!(&mut date_str, "{}D", self.days)?; |
225 | 226 | } |
226 | 227 |
|
227 | 228 | let mut time_str = String::new(); |
228 | 229 | if self.hours > 0 { |
229 | | - time_str.push_str(&format!("{}H", self.hours)); |
| 230 | + write!(&mut time_str, "{}H", self.hours)?; |
230 | 231 | } |
231 | 232 | if self.minutes > 0 { |
232 | | - time_str.push_str(&format!("{}M", self.minutes)); |
| 233 | + write!(&mut time_str, "{}M", self.minutes)?; |
233 | 234 | } |
234 | 235 | if self.seconds > 0.0 { |
235 | | - time_str.push_str(&format!("{}S", self.seconds)); |
| 236 | + write!(&mut time_str, "{}S", self.seconds)?; |
236 | 237 | } |
237 | 238 |
|
238 | 239 | if time_str.is_empty() { |
|
0 commit comments