Skip to content

Commit

Permalink
fixup: Some TLC for msrv.
Browse files Browse the repository at this point in the history
  • Loading branch information
tormeh committed Mar 8, 2023
1 parent f635bd1 commit a8edf1a
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 51 deletions.
8 changes: 4 additions & 4 deletions src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<Tz: TimeZone> Date<Tz> {
//
// note: this constructor is purposely not named to `new` to discourage the direct usage.
#[inline]
pub const fn from_utc(date: NaiveDate, offset: Tz::Offset) -> Date<Tz> {
pub fn from_utc(date: NaiveDate, offset: Tz::Offset) -> Date<Tz> {
Date { date, offset }
}

Expand Down Expand Up @@ -227,7 +227,7 @@ impl<Tz: TimeZone> Date<Tz> {

/// Retrieves an associated offset from UTC.
#[inline]
pub const fn offset(&self) -> &Tz::Offset {
pub fn offset(&self) -> &Tz::Offset {
&self.offset
}

Expand Down Expand Up @@ -274,7 +274,7 @@ impl<Tz: TimeZone> Date<Tz> {

/// Returns a view to the naive UTC date.
#[inline]
pub const fn naive_utc(&self) -> NaiveDate {
pub fn naive_utc(&self) -> NaiveDate {
self.date
}

Expand All @@ -284,7 +284,7 @@ impl<Tz: TimeZone> Date<Tz> {
/// because the offset is restricted to never exceed one day,
/// but provided for the consistency.
#[inline]
pub const fn naive_local(&self) -> NaiveDate {
pub fn naive_local(&self) -> NaiveDate {
self.date
}

Expand Down
6 changes: 3 additions & 3 deletions src/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<Tz: TimeZone> DateTime<Tz> {
//
// note: this constructor is purposely not named to `new` to discourage the direct usage.
#[inline]
pub const fn from_utc(datetime: NaiveDateTime, offset: Tz::Offset) -> DateTime<Tz> {
pub fn from_utc(datetime: NaiveDateTime, offset: Tz::Offset) -> DateTime<Tz> {
DateTime { datetime, offset }
}

Expand Down Expand Up @@ -293,7 +293,7 @@ impl<Tz: TimeZone> DateTime<Tz> {

/// Retrieves an associated offset from UTC.
#[inline]
pub const fn offset(&self) -> &Tz::Offset {
pub fn offset(&self) -> &Tz::Offset {
&self.offset
}

Expand Down Expand Up @@ -385,7 +385,7 @@ impl<Tz: TimeZone> DateTime<Tz> {

/// Returns a view to the naive UTC datetime.
#[inline]
pub const fn naive_utc(&self) -> NaiveDateTime {
pub fn naive_utc(&self) -> NaiveDateTime {
self.datetime
}

Expand Down
16 changes: 8 additions & 8 deletions src/format/locales.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
use pure_rust_locales::{locale_match, Locale};

pub(crate) const fn short_months(locale: Locale) -> &'static [&'static str] {
pub(crate) fn short_months(locale: Locale) -> &'static [&'static str] {
locale_match!(locale => LC_TIME::ABMON)
}

pub(crate) const fn long_months(locale: Locale) -> &'static [&'static str] {
pub(crate) fn long_months(locale: Locale) -> &'static [&'static str] {
locale_match!(locale => LC_TIME::MON)
}

pub(crate) const fn short_weekdays(locale: Locale) -> &'static [&'static str] {
pub(crate) fn short_weekdays(locale: Locale) -> &'static [&'static str] {
locale_match!(locale => LC_TIME::ABDAY)
}

pub(crate) const fn long_weekdays(locale: Locale) -> &'static [&'static str] {
pub(crate) fn long_weekdays(locale: Locale) -> &'static [&'static str] {
locale_match!(locale => LC_TIME::DAY)
}

pub(crate) const fn am_pm(locale: Locale) -> &'static [&'static str] {
pub(crate) fn am_pm(locale: Locale) -> &'static [&'static str] {
locale_match!(locale => LC_TIME::AM_PM)
}

pub(crate) const fn d_fmt(locale: Locale) -> &'static str {
pub(crate) fn d_fmt(locale: Locale) -> &'static str {
locale_match!(locale => LC_TIME::D_FMT)
}

pub(crate) const fn d_t_fmt(locale: Locale) -> &'static str {
pub(crate) fn d_t_fmt(locale: Locale) -> &'static str {
locale_match!(locale => LC_TIME::D_T_FMT)
}

pub(crate) const fn t_fmt(locale: Locale) -> &'static str {
pub(crate) fn t_fmt(locale: Locale) -> &'static str {
locale_match!(locale => LC_TIME::T_FMT)
}
8 changes: 2 additions & 6 deletions src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,11 +867,7 @@ pub struct DelayedFormat<I> {
#[cfg(any(feature = "alloc", feature = "std", test))]
impl<'a, I: Iterator<Item = B> + Clone, B: Borrow<Item<'a>>> DelayedFormat<I> {
/// Makes a new `DelayedFormat` value out of local date and time.
pub const fn new(
date: Option<NaiveDate>,
time: Option<NaiveTime>,
items: I,
) -> DelayedFormat<I> {
pub fn new(date: Option<NaiveDate>, time: Option<NaiveTime>, items: I) -> DelayedFormat<I> {
DelayedFormat {
date,
time,
Expand Down Expand Up @@ -906,7 +902,7 @@ impl<'a, I: Iterator<Item = B> + Clone, B: Borrow<Item<'a>>> DelayedFormat<I> {
/// Makes a new `DelayedFormat` value out of local date and time and locale.
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
pub const fn new_with_locale(
pub fn new_with_locale(
date: Option<NaiveDate>,
time: Option<NaiveTime>,
items: I,
Expand Down
2 changes: 1 addition & 1 deletion src/format/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ fn timezone_offset_internal<F>(
where
F: FnMut(&str) -> ParseResult<&str>,
{
const fn digits(s: &str) -> ParseResult<(u8, u8)> {
fn digits(s: &str) -> ParseResult<(u8, u8)> {
let b = s.as_bytes();
if b.len() < 2 {
Err(TOO_SHORT)
Expand Down
8 changes: 4 additions & 4 deletions src/month.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Month {
/// ----------- | --------- | ---------- | --- | ---------
/// `m.succ()`: | `February` | `March` | `...` | `January`
#[inline]
pub const fn succ(&self) -> Month {
pub fn succ(&self) -> Month {
match *self {
Month::January => Month::February,
Month::February => Month::March,
Expand All @@ -88,7 +88,7 @@ impl Month {
/// ----------- | --------- | ---------- | --- | ---------
/// `m.pred()`: | `December` | `January` | `...` | `November`
#[inline]
pub const fn pred(&self) -> Month {
pub fn pred(&self) -> Month {
match *self {
Month::January => Month::December,
Month::February => Month::January,
Expand All @@ -111,7 +111,7 @@ impl Month {
/// -------------------------| --------- | ---------- | --- | -----
/// `m.number_from_month()`: | 1 | 2 | `...` | 12
#[inline]
pub const fn number_from_month(&self) -> u32 {
pub fn number_from_month(&self) -> u32 {
match *self {
Month::January => 1,
Month::February => 2,
Expand All @@ -135,7 +135,7 @@ impl Month {
///
/// assert_eq!(Month::January.name(), "January")
/// ```
pub const fn name(&self) -> &'static str {
pub fn name(&self) -> &'static str {
match *self {
Month::January => "January",
Month::February => "February",
Expand Down
4 changes: 2 additions & 2 deletions src/naive/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ impl NaiveDate {
#[cfg(any(feature = "alloc", feature = "std", test))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[inline]
pub const fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>
pub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>
where
I: Iterator<Item = B> + Clone,
B: Borrow<Item<'a>>,
Expand Down Expand Up @@ -1167,7 +1167,7 @@ impl NaiveDate {
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
#[inline]
pub const fn format_localized_with_items<'a, I, B>(
pub fn format_localized_with_items<'a, I, B>(
&self,
items: I,
locale: Locale,
Expand Down
2 changes: 1 addition & 1 deletion src/naive/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ impl NaiveDateTime {
#[cfg(any(feature = "alloc", feature = "std", test))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[inline]
pub const fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>
pub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>
where
I: Iterator<Item = B> + Clone,
B: Borrow<Item<'a>>,
Expand Down
2 changes: 1 addition & 1 deletion src/naive/datetime/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ enum SerdeError<V: fmt::Display, D: fmt::Display> {
}

/// Construct a [`SerdeError::NonExistent`]
const fn ne_timestamp<T: fmt::Display>(ts: T) -> SerdeError<T, u8> {
fn ne_timestamp<T: fmt::Display>(ts: T) -> SerdeError<T, u8> {
SerdeError::NonExistent::<T, u8> { timestamp: ts }
}

Expand Down
6 changes: 3 additions & 3 deletions src/naive/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl Of {
}

#[inline]
pub(super) const fn with_ordinal(&self, ordinal: u32) -> Option<Of> {
pub(super) fn with_ordinal(&self, ordinal: u32) -> Option<Of> {
if ordinal > 366 {
return None;
}
Expand Down Expand Up @@ -404,7 +404,7 @@ impl Mdf {
}

#[inline]
pub(super) const fn with_month(&self, month: u32) -> Option<Mdf> {
pub(super) fn with_month(&self, month: u32) -> Option<Mdf> {
if month > 12 {
return None;
}
Expand All @@ -420,7 +420,7 @@ impl Mdf {
}

#[inline]
pub(super) const fn with_day(&self, day: u32) -> Option<Mdf> {
pub(super) fn with_day(&self, day: u32) -> Option<Mdf> {
if day > 31 {
return None;
}
Expand Down
8 changes: 4 additions & 4 deletions src/naive/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl NaiveTime {
/// assert!(from_hms_opt(23, 59, 60).is_none());
/// ```
#[inline]
pub const fn from_hms_opt(hour: u32, min: u32, sec: u32) -> Option<NaiveTime> {
pub fn from_hms_opt(hour: u32, min: u32, sec: u32) -> Option<NaiveTime> {
NaiveTime::from_hms_nano_opt(hour, min, sec, 0)
}

Expand Down Expand Up @@ -358,7 +358,7 @@ impl NaiveTime {
/// assert!(from_hmsn_opt(23, 59, 59, 2_000_000_000).is_none());
/// ```
#[inline]
pub const fn from_hms_nano_opt(hour: u32, min: u32, sec: u32, nano: u32) -> Option<NaiveTime> {
pub fn from_hms_nano_opt(hour: u32, min: u32, sec: u32, nano: u32) -> Option<NaiveTime> {
if hour >= 24 || min >= 60 || sec >= 60 || nano >= 2_000_000_000 {
return None;
}
Expand Down Expand Up @@ -399,7 +399,7 @@ impl NaiveTime {
/// assert!(from_nsecs_opt(86399, 2_000_000_000).is_none());
/// ```
#[inline]
pub const fn from_num_seconds_from_midnight_opt(secs: u32, nano: u32) -> Option<NaiveTime> {
pub fn from_num_seconds_from_midnight_opt(secs: u32, nano: u32) -> Option<NaiveTime> {
if secs >= 86_400 || nano >= 2_000_000_000 {
return None;
}
Expand Down Expand Up @@ -696,7 +696,7 @@ impl NaiveTime {
#[cfg(any(feature = "alloc", feature = "std", test))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[inline]
pub const fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>
pub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>
where
I: Iterator<Item = B> + Clone,
B: Borrow<Item<'a>>,
Expand Down
4 changes: 2 additions & 2 deletions src/offset/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl FixedOffset {
/// .and_hms_opt(0, 0, 0).unwrap();
/// assert_eq!(&datetime.to_rfc3339(), "2016-11-08T00:00:00+05:00")
/// ```
pub const fn east_opt(secs: i32) -> Option<FixedOffset> {
pub fn east_opt(secs: i32) -> Option<FixedOffset> {
if -86_400 < secs && secs < 86_400 {
Some(FixedOffset { local_minus_utc: secs })
} else {
Expand Down Expand Up @@ -83,7 +83,7 @@ impl FixedOffset {
/// .and_hms_opt(0, 0, 0).unwrap();
/// assert_eq!(&datetime.to_rfc3339(), "2016-11-08T00:00:00-05:00")
/// ```
pub const fn west_opt(secs: i32) -> Option<FixedOffset> {
pub fn west_opt(secs: i32) -> Option<FixedOffset> {
if -86_400 < secs && secs < 86_400 {
Some(FixedOffset { local_minus_utc: -secs })
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/offset/local/tz_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl From<Utf8Error> for Error {

// MSRV: 1.38
#[inline]
const fn rem_euclid(v: i64, rhs: i64) -> i64 {
fn rem_euclid(v: i64, rhs: i64) -> i64 {
let r = v % rhs;
if r < 0 {
if rhs < 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/offset/local/tz_info/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<'a> Cursor<'a> {
}

/// Returns `true` if data is remaining
pub(crate) const fn is_empty(&self) -> bool {
pub(crate) fn is_empty(&self) -> bool {
self.remaining.is_empty()
}

Expand Down
8 changes: 4 additions & 4 deletions src/offset/local/tz_info/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub(super) struct AlternateTime {

impl AlternateTime {
/// Construct a transition rule representing alternate local time types
const fn new(
fn new(
std: LocalTimeType,
dst: LocalTimeType,
dst_start: RuleDay,
Expand Down Expand Up @@ -504,7 +504,7 @@ impl RuleDay {
}

/// Construct a transition rule day represented by a zero-based Julian day in `[0, 365]`, taking occasional Feb 29 into account
const fn julian_0(julian_day_0: u16) -> Result<Self, Error> {
fn julian_0(julian_day_0: u16) -> Result<Self, Error> {
if julian_day_0 > 365 {
return Err(Error::TransitionRule("invalid rule day julian day"));
}
Expand Down Expand Up @@ -737,7 +737,7 @@ const DAY_IN_MONTHS_LEAP_YEAR_FROM_MARCH: [i64; 12] =
/// * `year`: Year
/// * `month`: Month in `[1, 12]`
/// * `month_day`: Day of the month in `[1, 31]`
pub(crate) const fn days_since_unix_epoch(year: i32, month: usize, month_day: i64) -> i64 {
pub(crate) fn days_since_unix_epoch(year: i32, month: usize, month_day: i64) -> i64 {
let is_leap_year = is_leap_year(year);

let year = year as i64;
Expand Down Expand Up @@ -768,7 +768,7 @@ pub(crate) const fn days_since_unix_epoch(year: i32, month: usize, month_day: i6
}

/// Check if a year is a leap year
pub(crate) const fn is_leap_year(year: i32) -> bool {
pub(crate) fn is_leap_year(year: i32) -> bool {
year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)
}

Expand Down
6 changes: 3 additions & 3 deletions src/offset/local/tz_info/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl<'a> TimeZoneRef<'a> {
}

/// Convert Unix time to Unix leap time, from the list of leap seconds in a time zone
const fn unix_time_to_unix_leap_time(&self, unix_time: i64) -> Result<i64, Error> {
fn unix_time_to_unix_leap_time(&self, unix_time: i64) -> Result<i64, Error> {
let mut unix_leap_time = unix_time;

let mut i = 0;
Expand Down Expand Up @@ -563,7 +563,7 @@ impl LocalTimeType {
}

/// Construct a local time type with the specified UTC offset in seconds
pub(super) const fn with_offset(ut_offset: i32) -> Result<Self, Error> {
pub(super) fn with_offset(ut_offset: i32) -> Result<Self, Error> {
if ut_offset == i32::min_value() {
return Err(Error::LocalTimeType("invalid UTC offset"));
}
Expand Down Expand Up @@ -608,7 +608,7 @@ fn find_tz_file(path: impl AsRef<Path>) -> Result<File, Error> {
}

#[inline]
const fn saturating_abs(v: i32) -> i32 {
fn saturating_abs(v: i32) -> i32 {
if v.is_positive() {
v
} else if v == i32::min_value() {
Expand Down
2 changes: 1 addition & 1 deletion src/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ where
}

// Return the maximum span in nanoseconds for the target number of digits.
const fn span_for_digits(digits: u16) -> u32 {
fn span_for_digits(digits: u16) -> u32 {
// fast lookup form of: 10^(9-min(9,digits))
match digits {
0 => 1_000_000_000,
Expand Down
4 changes: 2 additions & 2 deletions src/weekday.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Weekday {
/// ----------- | ----- | ----- | ----- | ----- | ----- | ----- | -----
/// `w.succ()`: | `Tue` | `Wed` | `Thu` | `Fri` | `Sat` | `Sun` | `Mon`
#[inline]
pub const fn succ(&self) -> Weekday {
pub fn succ(&self) -> Weekday {
match *self {
Weekday::Mon => Weekday::Tue,
Weekday::Tue => Weekday::Wed,
Expand All @@ -54,7 +54,7 @@ impl Weekday {
/// ----------- | ----- | ----- | ----- | ----- | ----- | ----- | -----
/// `w.pred()`: | `Sun` | `Mon` | `Tue` | `Wed` | `Thu` | `Fri` | `Sat`
#[inline]
pub const fn pred(&self) -> Weekday {
pub fn pred(&self) -> Weekday {
match *self {
Weekday::Mon => Weekday::Sun,
Weekday::Tue => Weekday::Mon,
Expand Down

0 comments on commit a8edf1a

Please sign in to comment.