From 73c21ae0a97c1ea43874d6063d99698339149da5 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Wed, 18 Dec 2019 18:59:53 +0300 Subject: [PATCH] refactor: enable clippy::unreadable_literal --- src/constants.rs | 2 +- src/contact.rs | 6 +++--- src/dc_tools.rs | 6 +++--- src/lib.rs | 2 +- src/message.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index ac4f29c1f..bb4d2f142 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -114,7 +114,7 @@ pub const DC_MSG_ID_LAST_SPECIAL: u32 = 9; /// approx. max. length returned by dc_msg_get_text() const DC_MAX_GET_TEXT_LEN: usize = 30000; /// approx. max. length returned by dc_get_msg_info() -const DC_MAX_GET_INFO_LEN: usize = 100000; +const DC_MAX_GET_INFO_LEN: usize = 100_000; pub const DC_CONTACT_ID_UNDEFINED: u32 = 0; pub const DC_CONTACT_ID_SELF: u32 = 1; diff --git a/src/contact.rs b/src/contact.rs index dd4acd129..bd1cb1b3a 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -100,11 +100,11 @@ pub enum Origin { /// address is in our address book AdressBook = 0x80000, /// set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! - SecurejoinInvited = 0x1000000, + SecurejoinInvited = 0x0100_0000, /// set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! - SecurejoinJoined = 0x2000000, + SecurejoinJoined = 0x0200_0000, /// contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names - ManuallyCreated = 0x4000000, + ManuallyCreated = 0x0400_0000, } impl Default for Origin { diff --git a/src/dc_tools.rs b/src/dc_tools.rs index 5eae390e4..54d4e22bb 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -49,8 +49,8 @@ pub(crate) fn dc_truncate(buf: &str, approx_chars: usize, do_unwrap: bool) -> Co /// - harmonize together while being different enough /// (therefore, we cannot just use random rgb colors :) const COLORS: [u32; 16] = [ - 0xe56555, 0xf28c48, 0x8e85ee, 0x76c84d, 0x5bb6cc, 0x549cdd, 0xd25c99, 0xb37800, 0xf23030, - 0x39b249, 0xbb243b, 0x964078, 0x66874f, 0x308ab9, 0x127ed0, 0xbe450c, + 0xe5_65_55, 0xf2_8c_48, 0x8e_85_ee, 0x76_c8_4d, 0x5b_b6_cc, 0x54_9c_dd, 0xd2_5c_99, 0xb3_78_00, + 0xf2_30_30, 0x39_b2_49, 0xbb_24_3b, 0x96_40_78, 0x66_87_4f, 0x30_8a_b9, 0x12_7e_d0, 0xbe_45_0c, ]; pub(crate) fn dc_str_to_color(s: impl AsRef) -> u32 { @@ -59,7 +59,7 @@ pub(crate) fn dc_str_to_color(s: impl AsRef) -> u32 { let bytes = str_lower.as_bytes(); for (i, byte) in bytes.iter().enumerate() { checksum += (i + 1) * *byte as usize; - checksum %= 0xffffff; + checksum %= 0x00ff_ffff; } let color_index = checksum % COLORS.len(); diff --git a/src/lib.rs b/src/lib.rs index ed934d4f7..7b20a4e79 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![deny(clippy::correctness, missing_debug_implementations, clippy::all)] // for now we hide warnings to not clutter/hide errors during "cargo clippy" #![allow(clippy::cognitive_complexity, clippy::too_many_arguments)] -#![allow(clippy::unreadable_literal, clippy::match_bool)] +#![allow(clippy::match_bool)] #![feature(ptr_wrapping_offset_from)] #![feature(drain_filter)] diff --git a/src/message.rs b/src/message.rs index 6a99c7029..26b57388b 100644 --- a/src/message.rs +++ b/src/message.rs @@ -720,7 +720,7 @@ pub fn get_msg_info(context: &Context, msg_id: MsgId) -> String { return ret; } let rawtxt = rawtxt.unwrap_or_default(); - let rawtxt = dc_truncate(rawtxt.trim(), 100000, false); + let rawtxt = dc_truncate(rawtxt.trim(), 100_000, false); let fts = dc_timestamp_to_str(msg.get_timestamp()); ret += &format!("Sent: {}", fts);