From c6f4fb5f7d85dfa6cbdbcb89fc3e403a77f71557 Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 10 Oct 2022 20:00:29 +0200 Subject: [PATCH] remove the warnings --- dump/src/lib.rs | 2 +- dump/src/reader/v4/tasks.rs | 55 ------------------------------------- dump/src/writer.rs | 2 +- 3 files changed, 2 insertions(+), 57 deletions(-) diff --git a/dump/src/lib.rs b/dump/src/lib.rs index fe69abb2f..f2090dace 100644 --- a/dump/src/lib.rs +++ b/dump/src/lib.rs @@ -47,7 +47,7 @@ pub enum Version { pub(crate) mod test { use std::{ fs::File, - io::{Read, Seek, SeekFrom}, + io::{Seek, SeekFrom}, str::FromStr, }; diff --git a/dump/src/reader/v4/tasks.rs b/dump/src/reader/v4/tasks.rs index dfe5452d8..dd00e780f 100644 --- a/dump/src/reader/v4/tasks.rs +++ b/dump/src/reader/v4/tasks.rs @@ -136,58 +136,3 @@ impl std::ops::Deref for IndexUid { &self.0 } } - -/// Serialize a `time::Duration` as a best effort ISO 8601 while waiting for -/// https://github.com/time-rs/time/issues/378. -/// This code is a port of the old code of time that was removed in 0.2. -#[cfg(test)] -fn serialize_duration( - duration: &Option, - serializer: S, -) -> Result { - use std::fmt::Write; - use time::Duration; - - match duration { - Some(duration) => { - // technically speaking, negative duration is not valid ISO 8601 - if duration.is_negative() { - return serializer.serialize_none(); - } - - const SECS_PER_DAY: i64 = Duration::DAY.whole_seconds(); - let secs = duration.whole_seconds(); - let days = secs / SECS_PER_DAY; - let secs = secs - days * SECS_PER_DAY; - let hasdate = days != 0; - let nanos = duration.subsec_nanoseconds(); - let hastime = (secs != 0 || nanos != 0) || !hasdate; - - // all the following unwrap can't fail - let mut res = String::new(); - write!(&mut res, "P").unwrap(); - - if hasdate { - write!(&mut res, "{}D", days).unwrap(); - } - - const NANOS_PER_MILLI: i32 = Duration::MILLISECOND.subsec_nanoseconds(); - const NANOS_PER_MICRO: i32 = Duration::MICROSECOND.subsec_nanoseconds(); - - if hastime { - if nanos == 0 { - write!(&mut res, "T{}S", secs).unwrap(); - } else if nanos % NANOS_PER_MILLI == 0 { - write!(&mut res, "T{}.{:03}S", secs, nanos / NANOS_PER_MILLI).unwrap(); - } else if nanos % NANOS_PER_MICRO == 0 { - write!(&mut res, "T{}.{:06}S", secs, nanos / NANOS_PER_MICRO).unwrap(); - } else { - write!(&mut res, "T{}.{:09}S", secs, nanos).unwrap(); - } - } - - serializer.serialize_str(&res) - } - None => serializer.serialize_none(), - } -} diff --git a/dump/src/writer.rs b/dump/src/writer.rs index 824e403c6..ba2caa85f 100644 --- a/dump/src/writer.rs +++ b/dump/src/writer.rs @@ -1,6 +1,6 @@ use std::{ fs::{self, File}, - io::{BufReader, BufWriter, Read, Write}, + io::{BufWriter, Write}, path::PathBuf, };