mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-09 13:39:46 -05:00
address some no-op clippy warnings
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
//! Clock interface and implementations for testability.
|
||||
|
||||
use failure::Error;
|
||||
use libc;
|
||||
use log::warn;
|
||||
use parking_lot::Mutex;
|
||||
use std::mem;
|
||||
@@ -136,7 +135,7 @@ struct SimulatedClocksInner {
|
||||
impl SimulatedClocks {
|
||||
pub fn new(boot: Timespec) -> Self {
|
||||
SimulatedClocks(Arc::new(SimulatedClocksInner {
|
||||
boot: boot,
|
||||
boot,
|
||||
uptime: Mutex::new(Duration::seconds(0)),
|
||||
}))
|
||||
}
|
||||
@@ -163,7 +162,7 @@ impl Clocks for SimulatedClocks {
|
||||
timeout: StdDuration,
|
||||
) -> Result<T, mpsc::RecvTimeoutError> {
|
||||
let r = rcv.recv_timeout(StdDuration::new(0, 0));
|
||||
if let Err(_) = r {
|
||||
if r.is_err() {
|
||||
self.sleep(Duration::from_std(timeout).unwrap());
|
||||
}
|
||||
r
|
||||
|
||||
@@ -27,7 +27,7 @@ pub fn encode_size(mut raw: i64) -> String {
|
||||
raw &= (1i64 << n) - 1;
|
||||
}
|
||||
}
|
||||
if raw > 0 || encoded.len() == 0 {
|
||||
if raw > 0 || encoded.is_empty() {
|
||||
write!(&mut encoded, "{}", raw).unwrap();
|
||||
} else {
|
||||
encoded.pop(); // remove trailing space.
|
||||
@@ -39,7 +39,7 @@ fn decode_sizepart(input: &str) -> IResult<&str, i64> {
|
||||
map(
|
||||
tuple((
|
||||
map_res(take_while1(|c: char| c.is_ascii_digit()), |input: &str| {
|
||||
i64::from_str_radix(input, 10)
|
||||
input.parse::<i64>()
|
||||
}),
|
||||
opt(alt((
|
||||
nom::combinator::value(1 << 40, tag("T")),
|
||||
|
||||
@@ -13,7 +13,6 @@ use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use std::ops;
|
||||
use std::str::FromStr;
|
||||
use time;
|
||||
|
||||
type IResult<'a, I, O> = nom::IResult<I, O, nom::error::VerboseError<&'a str>>;
|
||||
|
||||
@@ -27,7 +26,7 @@ pub struct Time(pub i64);
|
||||
fn fixed_len_num<'a>(len: usize) -> impl FnMut(&'a str) -> IResult<&'a str, i32> {
|
||||
map_res(
|
||||
take_while_m_n(len, len, |c: char| c.is_ascii_digit()),
|
||||
|input: &str| i32::from_str_radix(input, 10),
|
||||
|input: &str| input.parse::<i32>(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -96,9 +95,8 @@ impl Time {
|
||||
/// local time zone.
|
||||
pub fn parse(input: &str) -> Result<Self, Error> {
|
||||
// First try parsing as 90,000ths of a second since epoch.
|
||||
match i64::from_str(input) {
|
||||
Ok(i) => return Ok(Time(i)),
|
||||
Err(_) => {}
|
||||
if let Ok(i) = i64::from_str(input) {
|
||||
return Ok(Time(i));
|
||||
}
|
||||
|
||||
// If that failed, parse as a time string or bust.
|
||||
@@ -113,7 +111,7 @@ impl Time {
|
||||
format_err!("{}", nom::error::convert_error(input, e))
|
||||
}
|
||||
})?;
|
||||
if remaining != "" {
|
||||
if !remaining.is_empty() {
|
||||
bail!("unexpected suffix {:?} following time string", remaining);
|
||||
}
|
||||
let (tm_hour, tm_min, tm_sec, subsec) = opt_time.unwrap_or((0, 0, 0, 0));
|
||||
@@ -210,7 +208,7 @@ impl fmt::Display for Time {
|
||||
write!(
|
||||
f,
|
||||
"{}:{:05}{}{:02}:{:02}",
|
||||
tm.strftime("%FT%T").or_else(|_| Err(fmt::Error))?,
|
||||
tm.strftime("%FT%T").map_err(|_| fmt::Error)?,
|
||||
self.0 % TIME_UNITS_PER_SEC,
|
||||
if tm.tm_utcoff > 0 { '+' } else { '-' },
|
||||
zone_minutes / 60,
|
||||
|
||||
Reference in New Issue
Block a user