Fix two +nightly clippy suggestions

This commit is contained in:
Alexander Krotov
2020-06-23 02:26:13 +03:00
committed by link2xt
parent 545ff4f7ba
commit a031151587
2 changed files with 6 additions and 9 deletions

View File

@@ -1001,13 +1001,13 @@ impl rusqlite::types::ToSql for ChatVisibility {
impl rusqlite::types::FromSql for ChatVisibility { impl rusqlite::types::FromSql for ChatVisibility {
fn column_result(value: rusqlite::types::ValueRef) -> rusqlite::types::FromSqlResult<Self> { fn column_result(value: rusqlite::types::ValueRef) -> rusqlite::types::FromSqlResult<Self> {
i64::column_result(value).and_then(|val| { i64::column_result(value).map(|val| {
match val { match val {
2 => Ok(ChatVisibility::Pinned), 2 => ChatVisibility::Pinned,
1 => Ok(ChatVisibility::Archived), 1 => ChatVisibility::Archived,
0 => Ok(ChatVisibility::Normal), 0 => ChatVisibility::Normal,
// fallback to to Normal for unknown values, may happen eg. on imports created by a newer version. // fallback to to Normal for unknown values, may happen eg. on imports created by a newer version.
_ => Ok(ChatVisibility::Normal), _ => ChatVisibility::Normal,
} }
}) })
} }

View File

@@ -1,6 +1,5 @@
//! # [Autocrypt Peer State](https://autocrypt.org/level1.html#peer-state-management) module //! # [Autocrypt Peer State](https://autocrypt.org/level1.html#peer-state-management) module
use std::collections::HashSet; use std::collections::HashSet;
use std::convert::TryFrom;
use std::fmt; use std::fmt;
use num_traits::FromPrimitive; use num_traits::FromPrimitive;
@@ -324,11 +323,9 @@ impl<'a> Peerstate<'a> {
pub fn render_gossip_header(&self, min_verified: PeerstateVerifiedStatus) -> Option<String> { pub fn render_gossip_header(&self, min_verified: PeerstateVerifiedStatus) -> Option<String> {
if let Some(key) = self.peek_key(min_verified) { if let Some(key) = self.peek_key(min_verified) {
// TODO: avoid cloning
let public_key = SignedPublicKey::try_from(key.clone()).ok()?;
let header = Aheader::new( let header = Aheader::new(
self.addr.clone(), self.addr.clone(),
public_key, key.clone(), // TODO: avoid cloning
// Autocrypt 1.1.0 specification says that // Autocrypt 1.1.0 specification says that
// `prefer-encrypt` attribute SHOULD NOT be included, // `prefer-encrypt` attribute SHOULD NOT be included,
// but we include it anyway to propagate encryption // but we include it anyway to propagate encryption