Skip to content

Commit

Permalink
cluster: fix is_zero check for Rust < 1.53
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshgupta137 committed Jun 20, 2022
1 parent d7e463a commit e4f2914
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cluster.rs
Expand Up @@ -153,7 +153,8 @@ impl ClusterConnection {
/// block indefinitely. It is an error to pass the zero `Duration` to this
/// method.
pub fn set_write_timeout(&self, dur: Option<Duration>) -> RedisResult<()> {
if dur.is_some() && dur.unwrap().is_zero() {
// Check if duration is valid before updating local value.
if dur.is_some() && dur.unwrap() == Duration::default() {
return Err(RedisError::from((
ErrorKind::InvalidClientConfig,
"Duration should be None or non-zero.",
Expand All @@ -174,7 +175,8 @@ impl ClusterConnection {
/// block indefinitely. It is an error to pass the zero `Duration` to this
/// method.
pub fn set_read_timeout(&self, dur: Option<Duration>) -> RedisResult<()> {
if dur.is_some() && dur.unwrap().is_zero() {
// Check if duration is valid before updating local value.
if dur.is_some() && dur.unwrap() == Duration::default() {
return Err(RedisError::from((
ErrorKind::InvalidClientConfig,
"Duration should be None or non-zero.",
Expand Down

0 comments on commit e4f2914

Please sign in to comment.