Files
himalaya/src/email/message/arg/body.rs
T
Perma Alesheikh 0ff940871b use char when replacing a single character
Reasons:
- More idiomatic use of string.

Considering that they are constants, I don't anticipate any performance
gains related to heap-allocation.

Signed-off-by: Perma Alesheikh <me@prma.dev>
2024-01-09 21:55:20 +01:00

26 lines
569 B
Rust

use clap::Parser;
use std::ops::Deref;
/// The raw message body argument parser.
#[derive(Debug, Parser)]
pub struct MessageRawBodyArg {
/// Prefill the template with a custom body.
#[arg(trailing_var_arg = true)]
#[arg(name = "body_raw", value_name = "BODY")]
pub raw: Vec<String>,
}
impl MessageRawBodyArg {
pub fn raw(self) -> String {
self.raw.join(" ").replace('\r', "").replace('\n', "\r\n")
}
}
impl Deref for MessageRawBodyArg {
type Target = Vec<String>;
fn deref(&self) -> &Self::Target {
&self.raw
}
}