diff --git a/Cargo.toml b/Cargo.toml index 2277e93..922a561 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pg_interval" -version = "0.4.4" -edition = "2021" +version = "0.4.5" +edition = "2024" authors = ["Ryan Piper ", "Ning Sun "] license = "MIT" description = "A native PostgreSQL interval type" diff --git a/src/integrations/duration.rs b/src/integrations/duration.rs index caeaf00..50a2ca1 100644 --- a/src/integrations/duration.rs +++ b/src/integrations/duration.rs @@ -1,4 +1,4 @@ -use crate::{interval_norm::IntervalNorm, Interval}; +use crate::{Interval, interval_norm::IntervalNorm}; use chrono::Duration; const NANOS_PER_SEC: i64 = 1_000_000_000; diff --git a/src/integrations/rust_postgres.rs b/src/integrations/rust_postgres.rs index a841a7c..bd20c73 100644 --- a/src/integrations/rust_postgres.rs +++ b/src/integrations/rust_postgres.rs @@ -1,6 +1,6 @@ use crate::Interval; use bytes::{Buf, BufMut, BytesMut}; -use postgres_types::{to_sql_checked, FromSql, IsNull, ToSql, Type}; +use postgres_types::{FromSql, IsNull, ToSql, Type, to_sql_checked}; use std::error::Error; impl<'a> FromSql<'a> for Interval { diff --git a/src/interval_fmt/postgres.rs b/src/interval_fmt/postgres.rs index e6fde0a..b2fe5f4 100644 --- a/src/interval_fmt/postgres.rs +++ b/src/interval_fmt/postgres.rs @@ -1,43 +1,23 @@ use crate::interval_norm::IntervalNorm; fn get_year_suffix(value: i32) -> &'static str { - if value == 1 { - "year" - } else { - "years" - } + if value == 1 { "year" } else { "years" } } fn get_mon_suffix(value: i32) -> &'static str { - if value == 1 { - "mon" - } else { - "mons" - } + if value == 1 { "mon" } else { "mons" } } fn get_day_suffix(value: i32) -> &'static str { - if value == 1 { - "day" - } else { - "days" - } + if value == 1 { "day" } else { "days" } } fn get_hour_suffix(value: i64) -> &'static str { - if value == 1 { - "hour" - } else { - "hours" - } + if value == 1 { "hour" } else { "hours" } } fn get_min_suffix(value: i64) -> &'static str { - if value == 1 { - "min" - } else { - "mins" - } + if value == 1 { "min" } else { "mins" } } fn get_sec_suffix(seconds: i64, microseconds: i64) -> &'static str { diff --git a/src/interval_norm.rs b/src/interval_norm.rs index 0cced78..d34b361 100644 --- a/src/interval_norm.rs +++ b/src/interval_norm.rs @@ -1,4 +1,4 @@ -use crate::{interval_parse::parse_error::ParseError, Interval}; +use crate::{Interval, interval_parse::parse_error::ParseError}; pub struct IntervalNorm { pub years: i32, diff --git a/src/interval_parse/iso_8601.rs b/src/interval_parse/iso_8601.rs index 489f4ba..3046a35 100644 --- a/src/interval_parse/iso_8601.rs +++ b/src/interval_parse/iso_8601.rs @@ -1,9 +1,9 @@ use super::parse_error::ParseError; use super::{ - scale_date, scale_time, DAYS_PER_MONTH, HOURS_PER_DAY, MICROS_PER_SECOND, MINUTES_PER_HOUR, - MONTHS_PER_YEAR, SECONDS_PER_MIN, + DAYS_PER_MONTH, HOURS_PER_DAY, MICROS_PER_SECOND, MINUTES_PER_HOUR, MONTHS_PER_YEAR, + SECONDS_PER_MIN, scale_date, scale_time, }; -use crate::{interval_norm::IntervalNorm, Interval}; +use crate::{Interval, interval_norm::IntervalNorm}; enum ParserCode { BadFormat, diff --git a/src/interval_parse/postgres.rs b/src/interval_parse/postgres.rs index 9eae2db..55fa2c6 100644 --- a/src/interval_parse/postgres.rs +++ b/src/interval_parse/postgres.rs @@ -1,9 +1,9 @@ use super::parse_error::ParseError; -use crate::{interval_norm::IntervalNorm, Interval}; +use crate::{Interval, interval_norm::IntervalNorm}; use super::{ - scale_date, scale_time, DAYS_PER_MONTH, HOURS_PER_DAY, MICROS_PER_SECOND, MINUTES_PER_HOUR, - MONTHS_PER_YEAR, SECONDS_PER_MIN, + DAYS_PER_MONTH, HOURS_PER_DAY, MICROS_PER_SECOND, MINUTES_PER_HOUR, MONTHS_PER_YEAR, + SECONDS_PER_MIN, scale_date, scale_time, }; impl Interval { diff --git a/src/interval_parse/sql.rs b/src/interval_parse/sql.rs index 6e067d1..18ab84a 100644 --- a/src/interval_parse/sql.rs +++ b/src/interval_parse/sql.rs @@ -1,6 +1,6 @@ use super::parse_error::ParseError; -use crate::interval_norm::IntervalNorm; use crate::Interval; +use crate::interval_norm::IntervalNorm; impl Interval { pub fn from_sql(sql_str: &str) -> Result {