Unverified Commit c819930d authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

[chore] Upgrade to Rust 1.49.0 (#99)

parent e1b881b6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ on: [push]
name: CI

env:
  rust_version: 1.48.0
  rust_version: 1.49.0
  java_version: 9

jobs:
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@

const NANOS_PER_SECOND: u32 = 1_000_000_000;

#[non_exhaustive]
#[derive(Debug, Eq, PartialEq)]
pub enum DateParseError {
    Invalid(&'static str),
+6 −5
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
 * SPDX-License-Identifier: Apache-2.0.
 */

use crate::instant::format::DateParseError;
use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
use std::str::FromStr;
use std::time::{SystemTime, UNIX_EPOCH};
@@ -54,14 +55,14 @@ impl Instant {
        }
    }

    pub fn from_str(s: &str, format: Format) -> Result<Self, ()> {
    pub fn from_str(s: &str, format: Format) -> Result<Self, DateParseError> {
        match format {
            Format::DateTime => format::iso_8601::parse(s).map_err(|_| ()),
            Format::HttpDate => format::http_date::parse(s).map_err(|_| ()),
            Format::DateTime => format::iso_8601::parse(s),
            Format::HttpDate => format::http_date::parse(s),
            Format::EpochSeconds => <f64>::from_str(s)
                // TODO: Parse base & fraction separately to achieve higher precision
                .map(Self::from_f64)
                .map_err(|_| ()),
                .map_err(|_| DateParseError::Invalid("expected float")),
        }
    }

@@ -87,7 +88,7 @@ impl Instant {
    pub fn fmt(&self, format: Format) -> String {
        match format {
            Format::DateTime => {
                // TODO: hand write rfc3339 formatter & remove chrono dependency
                // TODO: hand write rfc3339 formatter & remove Chrono alloc feature
                let rfc3339 = self
                    .to_chrono()
                    .to_rfc3339_opts(SecondsFormat::AutoSi, true);