mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 21:06:31 +03:00
refactor: Use regular functions rather than FromStr impls (#8178)
Implementing `FromStr` and then calling `parse()` creates an indirection, which is hard to follow for people who are not familiar with Rust. @r10s recently voiced this problem when we were pair-programming, and I agree. We can decide what exactly to call the new function. I didn't remove all `FromStr` implementations yet; `FromStr for Fingerprint`, `FromStr for Params`, `FromStr for MozConfigTag` and `FromStr for EphemeralTimer` are still left.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use std::cmp;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::iter;
|
||||
use std::str::FromStr as _;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use anyhow::{Context as _, Result, ensure};
|
||||
@@ -1828,7 +1829,7 @@ async fn add_parts(
|
||||
// Extract ephemeral timer from the message
|
||||
let mut ephemeral_timer = if let Some(value) = mime_parser.get_header(HeaderDef::EphemeralTimer)
|
||||
{
|
||||
match value.parse::<EphemeralTimer>() {
|
||||
match EphemeralTimer::from_str(value) {
|
||||
Ok(timer) => timer,
|
||||
Err(err) => {
|
||||
warn!(context, "Can't parse ephemeral timer \"{value}\": {err:#}.");
|
||||
@@ -2106,7 +2107,7 @@ async fn add_parts(
|
||||
chat_id,
|
||||
from_id,
|
||||
sort_timestamp,
|
||||
Reaction::from(reaction_str.as_str()),
|
||||
Reaction::new(reaction_str.as_str()),
|
||||
is_incoming_fresh,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user