pydantic/speedate

Consider removing some warnings.

mkdir700 opened this issue · 1 comments

as title.

use make all that you will get the following warning message

error: boolean to int conversion using if
   --> src/date.rs:181:26
    |
181 |         let leap_extra = if is_leap_year(self.year) { 1 } else { 0 };
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `u16::from(is_leap_year(self.year))`
    |
    = note: `-D clippy::bool-to-int-with-if` implied by `-D warnings`
    = note: `is_leap_year(self.year) as u16` or `is_leap_year(self.year).into()` can also be valid options
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_to_int_with_if

error: single-character string constant used as pattern
  --> src/datetime.rs:45:81
   |
45 |             f.write_str(std::str::from_utf8(&buf[..]).unwrap().trim_end_matches("0"))?;
   |                                                                                 ^^^ help: try using a `char` instead: `'0'`
   |
   = note: `-D clippy::single-char-pattern` implied by `-D warnings`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern

error: single-character string constant used as pattern
  --> src/time.rs:47:81
   |
47 |             f.write_str(std::str::from_utf8(&buf[..]).unwrap().trim_end_matches("0"))
   |                                                                                 ^^^ help: try using a `char` instead: `'0'`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern

error: could not compile `speedate` due to 3 previous errors

This is just because clippy has added more warnings.

PR welcome to add an ignore to the first one and fix the second two.