From c819930d0fca642fdecbe248d1333c5a62207501 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Thu, 31 Dec 2020 16:09:58 -0500 Subject: [PATCH] [chore] Upgrade to Rust 1.49.0 (#99) --- .github/workflows/ci.yaml | 2 +- rust-runtime/smithy-types/src/instant/format.rs | 1 + rust-runtime/smithy-types/src/instant/mod.rs | 11 ++++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 29b9ed531..6ccf547fd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,7 +3,7 @@ on: [push] name: CI env: - rust_version: 1.48.0 + rust_version: 1.49.0 java_version: 9 jobs: diff --git a/rust-runtime/smithy-types/src/instant/format.rs b/rust-runtime/smithy-types/src/instant/format.rs index 89fac30d5..30e3862c6 100644 --- a/rust-runtime/smithy-types/src/instant/format.rs +++ b/rust-runtime/smithy-types/src/instant/format.rs @@ -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), diff --git a/rust-runtime/smithy-types/src/instant/mod.rs b/rust-runtime/smithy-types/src/instant/mod.rs index f37257a78..4dbb17e53 100644 --- a/rust-runtime/smithy-types/src/instant/mod.rs +++ b/rust-runtime/smithy-types/src/instant/mod.rs @@ -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 { + pub fn from_str(s: &str, format: Format) -> Result { 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 => ::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); -- GitLab