Skip to content

Commit 2ae6423

Browse files
piperRyansunng87
andauthored
chore: bump to rust 2024 edition (#82)
* chore: bump to 2024 edition * chore: format for 2024 --------- Co-authored-by: Ning Sun <sunning@greptime.com>
1 parent 4e58683 commit 2ae6423

File tree

8 files changed

+17
-37
lines changed

8 files changed

+17
-37
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "pg_interval"
3-
version = "0.4.4"
4-
edition = "2021"
3+
version = "0.4.5"
4+
edition = "2024"
55
authors = ["Ryan Piper <piper.ryan235@gmail.com>", "Ning Sun <n@sunng.info>"]
66
license = "MIT"
77
description = "A native PostgreSQL interval type"

src/integrations/duration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{interval_norm::IntervalNorm, Interval};
1+
use crate::{Interval, interval_norm::IntervalNorm};
22
use chrono::Duration;
33

44
const NANOS_PER_SEC: i64 = 1_000_000_000;

src/integrations/rust_postgres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::Interval;
22
use bytes::{Buf, BufMut, BytesMut};
3-
use postgres_types::{to_sql_checked, FromSql, IsNull, ToSql, Type};
3+
use postgres_types::{FromSql, IsNull, ToSql, Type, to_sql_checked};
44
use std::error::Error;
55

66
impl<'a> FromSql<'a> for Interval {

src/interval_fmt/postgres.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,23 @@
11
use crate::interval_norm::IntervalNorm;
22

33
fn get_year_suffix(value: i32) -> &'static str {
4-
if value == 1 {
5-
"year"
6-
} else {
7-
"years"
8-
}
4+
if value == 1 { "year" } else { "years" }
95
}
106

117
fn get_mon_suffix(value: i32) -> &'static str {
12-
if value == 1 {
13-
"mon"
14-
} else {
15-
"mons"
16-
}
8+
if value == 1 { "mon" } else { "mons" }
179
}
1810

1911
fn get_day_suffix(value: i32) -> &'static str {
20-
if value == 1 {
21-
"day"
22-
} else {
23-
"days"
24-
}
12+
if value == 1 { "day" } else { "days" }
2513
}
2614

2715
fn get_hour_suffix(value: i64) -> &'static str {
28-
if value == 1 {
29-
"hour"
30-
} else {
31-
"hours"
32-
}
16+
if value == 1 { "hour" } else { "hours" }
3317
}
3418

3519
fn get_min_suffix(value: i64) -> &'static str {
36-
if value == 1 {
37-
"min"
38-
} else {
39-
"mins"
40-
}
20+
if value == 1 { "min" } else { "mins" }
4121
}
4222

4323
fn get_sec_suffix(seconds: i64, microseconds: i64) -> &'static str {

src/interval_norm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{interval_parse::parse_error::ParseError, Interval};
1+
use crate::{Interval, interval_parse::parse_error::ParseError};
22

33
pub struct IntervalNorm {
44
pub years: i32,

src/interval_parse/iso_8601.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::parse_error::ParseError;
22
use super::{
3-
scale_date, scale_time, DAYS_PER_MONTH, HOURS_PER_DAY, MICROS_PER_SECOND, MINUTES_PER_HOUR,
4-
MONTHS_PER_YEAR, SECONDS_PER_MIN,
3+
DAYS_PER_MONTH, HOURS_PER_DAY, MICROS_PER_SECOND, MINUTES_PER_HOUR, MONTHS_PER_YEAR,
4+
SECONDS_PER_MIN, scale_date, scale_time,
55
};
6-
use crate::{interval_norm::IntervalNorm, Interval};
6+
use crate::{Interval, interval_norm::IntervalNorm};
77

88
enum ParserCode {
99
BadFormat,

src/interval_parse/postgres.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::parse_error::ParseError;
2-
use crate::{interval_norm::IntervalNorm, Interval};
2+
use crate::{Interval, interval_norm::IntervalNorm};
33

44
use super::{
5-
scale_date, scale_time, DAYS_PER_MONTH, HOURS_PER_DAY, MICROS_PER_SECOND, MINUTES_PER_HOUR,
6-
MONTHS_PER_YEAR, SECONDS_PER_MIN,
5+
DAYS_PER_MONTH, HOURS_PER_DAY, MICROS_PER_SECOND, MINUTES_PER_HOUR, MONTHS_PER_YEAR,
6+
SECONDS_PER_MIN, scale_date, scale_time,
77
};
88

99
impl Interval {

src/interval_parse/sql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::parse_error::ParseError;
2-
use crate::interval_norm::IntervalNorm;
32
use crate::Interval;
3+
use crate::interval_norm::IntervalNorm;
44

55
impl Interval {
66
pub fn from_sql(sql_str: &str) -> Result<Interval, ParseError> {

0 commit comments

Comments
 (0)