addressing clippy lints

This commit is contained in:
Aravinth Manivannan 2021-06-09 20:18:46 +05:30
parent 705c39af13
commit 0ff9cf9cb0
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
4 changed files with 18 additions and 26 deletions

View File

@ -48,7 +48,7 @@ impl HashCache {
// retrive [PoWConfig] from cache. Deletes config post retrival
fn retrive_pow_config(&mut self, string: String) -> CaptchaResult<Option<CachedPoWConfig>> {
if let Some(difficulty_factor) = self.remove_pow_config(&string) {
Ok(Some(difficulty_factor.to_owned()))
Ok(Some(difficulty_factor))
} else {
Ok(None)
}
@ -69,9 +69,9 @@ impl HashCache {
fn verify_captcha_result(&mut self, challenge: VerifyCaptchaResult) -> CaptchaResult<bool> {
if let Some(captcha_id) = self.remove_cache_result(&challenge.token) {
if captcha_id == challenge.key {
return Ok(true);
Ok(true)
} else {
return Ok(false);
Ok(false)
}
} else {
Ok(false)
@ -101,7 +101,7 @@ impl Handler<CachePoW> for HashCache {
let addr = ctx.address();
let del_msg = DeletePoW(msg.string.clone());
let duration: Duration = Duration::new(msg.duration.clone(), 0);
let duration: Duration = Duration::new(msg.duration, 0);
let wait_for = async move {
//sleep(duration).await;
delay_for(duration).await;
@ -144,7 +144,7 @@ impl Handler<CacheResult> for HashCache {
token: msg.token.clone(),
};
let duration: Duration = Duration::new(msg.duration.clone(), 0);
let duration: Duration = Duration::new(msg.duration, 0);
let wait_for = async move {
//sleep(duration).await;
delay_for(duration).await;

View File

@ -284,7 +284,7 @@ pub mod tests {
Some(CaptchaError::PleaseSetValue("defense".into()))
);
let m = MCaptchaBuilder::default().defense(defense.clone()).build();
let m = MCaptchaBuilder::default().defense(defense).build();
assert_eq!(
m.err(),
Some(CaptchaError::PleaseSetValue("duration".into()))

View File

@ -45,7 +45,7 @@ impl MasterTrait for Master {}
impl Master {
/// add [Counter] actor to [Master]
pub fn add_site(&mut self, addr: Addr<Counter>, id: String) {
self.sites.insert(id, (None, addr.to_owned()));
self.sites.insert(id, (None, addr));
}
/// create new master
@ -58,7 +58,7 @@ impl Master {
}
/// get [Counter] actor from [Master]
pub fn get_site<'a, 'b>(&'a mut self, id: &'b str) -> Option<Addr<Counter>> {
pub fn get_site(&mut self, id: &str) -> Option<Addr<Counter>> {
let mut r = None;
if let Some((read_val, addr)) = self.sites.get_mut(id) {
r = Some(addr.clone());
@ -111,7 +111,7 @@ impl Handler<AddVisitor> for Master {
ctx.spawn(fut);
}
}
return MessageResult(rx);
MessageResult(rx)
}
}
@ -125,10 +125,9 @@ impl Handler<GetSite> for Master {
fn handle(&mut self, m: GetSite, _ctx: &mut Self::Context) -> Self::Result {
let addr = self.get_site(&m.0);
if addr.is_none() {
return MessageResult(None);
} else {
return MessageResult(Some(addr.unwrap().clone()));
match addr {
None => MessageResult(None),
Some(addr) => MessageResult(Some(addr)),
}
}
}

View File

@ -77,24 +77,17 @@ impl MCaptchaRedisConnection {
let commands = vec![ADD_VISITOR, ADD_CAPTCHA, DEL, CAPTCHA_EXISTS, GET];
for cmd in commands.iter() {
match self
if let Value::Bulk(mut val) = self
.0
.exec(redis::cmd("COMMAND").arg(&["INFO", cmd]))
.await
.unwrap()
{
Value::Bulk(mut val) => {
match val.pop() {
Some(Value::Nil) => {
return Err(CaptchaError::MCaptchaRediSModuleCommandNotFound(
cmd.to_string(),
))
}
_ => (),
};
}
_ => (),
if let Some(Value::Nil) = val.pop() {
return Err(CaptchaError::MCaptchaRediSModuleCommandNotFound(
cmd.to_string(),
));
};
};
}