diff --git a/deltachat-rpc-server/src/main.rs b/deltachat-rpc-server/src/main.rs index bb3c83b84..1e2adb5e6 100644 --- a/deltachat-rpc-server/src/main.rs +++ b/deltachat-rpc-server/src/main.rs @@ -43,7 +43,7 @@ async fn main_impl() -> Result<()> { if let Some(arg) = args.next() { return Err(anyhow!("Unrecognized argument {arg:?}")); } - eprintln!("{}", &*DC_VERSION_STR); + eprintln!("{DC_VERSION_STR}"); return Ok(()); } else if first_arg.to_str() == Some("--openrpc") { if let Some(arg) = args.next() { diff --git a/src/config.rs b/src/config.rs index c065709be..62feb6bca 100644 --- a/src/config.rs +++ b/src/config.rs @@ -504,7 +504,7 @@ impl Context { .into_owned() }) } - Config::SysVersion => Some((*constants::DC_VERSION_STR).clone()), + Config::SysVersion => Some(constants::DC_VERSION_STR.to_string()), Config::SysMsgsizeMaxRecommended => Some(format!("{RECOMMENDED_FILE_SIZE}")), Config::SysConfigKeys => Some(get_config_keys_string()), _ => self.sql.get_raw_config(key.as_ref()).await?, diff --git a/src/constants.rs b/src/constants.rs index 01b847fb8..28eb4c0fe 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -2,16 +2,13 @@ #![allow(missing_docs)] -use std::sync::LazyLock; - use deltachat_derive::{FromSql, ToSql}; use percent_encoding::{AsciiSet, NON_ALPHANUMERIC}; use serde::{Deserialize, Serialize}; use crate::chat::ChatId; -pub static DC_VERSION_STR: LazyLock = - LazyLock::new(|| env!("CARGO_PKG_VERSION").to_string()); +pub static DC_VERSION_STR: &str = env!("CARGO_PKG_VERSION"); /// Set of characters to percent-encode in email addresses and names. pub(crate) const NON_ALPHANUMERIC_WITHOUT_DOT: &AsciiSet = &NON_ALPHANUMERIC.remove(b'.'); diff --git a/src/context.rs b/src/context.rs index c4bd71c52..afff22e5a 100644 --- a/src/context.rs +++ b/src/context.rs @@ -351,7 +351,7 @@ pub fn get_info() -> BTreeMap<&'static str, String> { #[cfg(not(debug_assertions))] res.insert("debug_assertions", "Off".to_string()); - res.insert("deltachat_core_version", format!("v{}", &*DC_VERSION_STR)); + res.insert("deltachat_core_version", format!("v{DC_VERSION_STR}")); res.insert("sqlite_version", rusqlite::version().to_string()); res.insert("arch", (std::mem::size_of::() * 8).to_string()); res.insert("num_cpus", num_cpus::get().to_string()); @@ -1334,10 +1334,5 @@ impl Context { } } -/// Returns core version as a string. -pub fn get_version_str() -> &'static str { - &DC_VERSION_STR -} - #[cfg(test)] mod context_tests; diff --git a/src/stats.rs b/src/stats.rs index 6d97262d9..33d9f7452 100644 --- a/src/stats.rs +++ b/src/stats.rs @@ -14,9 +14,9 @@ use serde::Serialize; use crate::chat::{self, ChatId, MuteDuration}; use crate::config::Config; -use crate::constants::Chattype; +use crate::constants::{Chattype, DC_VERSION_STR}; use crate::contact::{Contact, ContactId, Origin, import_vcard, mark_contact_id_as_verified}; -use crate::context::{Context, get_version_str}; +use crate::context::Context; use crate::key::load_self_public_keyring; use crate::log::LogExt; use crate::message::{Message, Viewtype}; @@ -356,7 +356,7 @@ async fn get_stats(context: &Context) -> Result { get_timestamps(context, "stats_sending_disabled_events").await?; let stats = Statistics { - core_version: get_version_str().to_string(), + core_version: DC_VERSION_STR.to_string(), key_create_timestamps, stats_id: stats_id(context).await?, is_chatmail: context.is_chatmail().await?, diff --git a/src/stats/stats_tests.rs b/src/stats/stats_tests.rs index 5fcbeb677..3a385b604 100644 --- a/src/stats/stats_tests.rs +++ b/src/stats/stats_tests.rs @@ -46,7 +46,7 @@ async fn test_maybe_send_stats() -> Result<()> { r.get("contact_stats").unwrap(), &serde_json::Value::Array(vec![]) ); - assert_eq!(r.get("core_version").unwrap(), get_version_str()); + assert_eq!(r.get("core_version").unwrap(), DC_VERSION_STR); assert_eq!(maybe_send_stats(alice).await?, None);