diff options
author | Pro <twisted.fall@gmail.com> | 2024-02-09 21:53:42 +0100 |
---|---|---|
committer | Pro <twisted.fall@gmail.com> | 2024-02-09 21:53:42 +0100 |
commit | 1ba7fa469d04530444eb0bc6d7c9ee2fd41457f6 (patch) | |
tree | cc732a509acad26a5f484246eefaddddde776154 /src/util.rs | |
parent | 3fe862d63b4be68f62f8de737c5322ce22ea8dd9 (diff) |
Bump edition to 2021 and introduce rustfmt
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/util.rs b/src/util.rs index 59ed2ea..efed210 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,7 +1,12 @@ #[inline] -pub fn adjust_times_add(mut y: i64, mut mo: i64, mut d: i64, mut h: i64, mut mi: i64, mut s: i64) - -> (i64, i64, i64, i64, i64, i64) -{ +pub fn adjust_times_add( + mut y: i64, + mut mo: i64, + mut d: i64, + mut h: i64, + mut mi: i64, + mut s: i64, +) -> (i64, i64, i64, i64, i64, i64) { // Subtract $border from the $base as long as the $base is bigger or equal to the $border. // The number of subtractions are added to $next. macro_rules! fix { @@ -33,12 +38,17 @@ pub fn adjust_times_add(mut y: i64, mut mo: i64, mut d: i64, mut h: i64, mut mi: } #[inline] -pub fn adjust_times_sub(mut y: i64, mut mo: i64, mut d: i64, mut h: i64, mut mi: i64, mut s: i64) - -> (i64, i64, i64, i64, i64, i64) -{ +pub fn adjust_times_sub( + mut y: i64, + mut mo: i64, + mut d: i64, + mut h: i64, + mut mi: i64, + mut s: i64, +) -> (i64, i64, i64, i64, i64, i64) { if s < 0 { mi -= (s.abs() / 60) + 1; - s = 60 - (0 - s).abs(); + s = 60 - (0 - s).abs(); } if mi < 0 { @@ -48,12 +58,12 @@ pub fn adjust_times_sub(mut y: i64, mut mo: i64, mut d: i64, mut h: i64, mut mi: if h < 0 { d -= (h.abs() / 24) + 1; - h = 24 - (0 - h).abs(); + h = 24 - (0 - h).abs(); } if d < 1 { mo -= (d.abs() / 32) + 1; - d = 31 - (0 - d).abs(); + d = 31 - (0 - d).abs(); } if mo < 1 { @@ -86,18 +96,22 @@ pub fn is_leap_year(y: i32) -> bool { #[test] fn test_is_leap_year() { - let leaps = [ 1880, 1884, 1888, 1892, 1896, 1904, 1908, 1912, 1916, 1920, 1924, 1928, 1932, - 1936, 1940, 1944, 1948, 1952, 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, - 1996, 2000, 2004, 2008, 2012, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048, 2052, 2056, - 2060, 2064, 2068, 2072, 2076, 2080, 2084, 2088, 2092, 2096, 2104, 2108, 2112, 2116, 2120, - 2124, 2128, 2132, 2136, 2140, 2144, 2148, 2152, 2156, 2160, 2164, 2168, 2172, 2176, 2180, - 2184, 2188, 2192, 2196, 2204, 2208 ]; + let leaps = [ + 1880, 1884, 1888, 1892, 1896, 1904, 1908, 1912, 1916, 1920, 1924, 1928, 1932, 1936, 1940, 1944, 1948, 1952, + 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000, 2004, 2008, 2012, 2020, 2024, 2028, + 2032, 2036, 2040, 2044, 2048, 2052, 2056, 2060, 2064, 2068, 2072, 2076, 2080, 2084, 2088, 2092, 2096, 2104, + 2108, 2112, 2116, 2120, 2124, 2128, 2132, 2136, 2140, 2144, 2148, 2152, 2156, 2160, 2164, 2168, 2172, 2176, + 2180, 2184, 2188, 2192, 2196, 2204, 2208, + ]; for i in leaps.iter() { assert!(is_leap_year(*i), "Is no leap year: {}", i); - assert!(!is_leap_year(*i + 1), "Seems to be leap year: {}, but should not be", i + 1); + assert!( + !is_leap_year(*i + 1), + "Seems to be leap year: {}, but should not be", + i + 1 + ); } - } #[test] |