melib: Replace String with Cow<'static, str>

async
Manos Pitsidianakis 2020-01-07 12:55:27 +02:00
parent 9fcc868acd
commit ca7d72e732
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
4 changed files with 10 additions and 10 deletions

View File

@ -619,7 +619,7 @@ pub fn select_response(input: &str) -> Result<SelectResponse> {
Ok(ret)
} else {
debug!("BAD/NO response in select: {}", input);
Err(MeliError::new(input))
Err(MeliError::new(input.to_string()))
}
}

View File

@ -37,14 +37,14 @@ pub type Result<T> = result::Result<T, MeliError>;
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MeliError {
pub summary: Option<String>,
pub details: String,
pub summary: Option<Cow<'static, str>>,
pub details: Cow<'static, str>,
}
impl MeliError {
pub fn new<M>(msg: M) -> MeliError
where
M: Into<String>,
M: Into<Cow<'static, str>>,
{
MeliError {
summary: None,
@ -54,7 +54,7 @@ impl MeliError {
pub fn set_summary<M>(mut self, summary: M) -> MeliError
where
M: Into<String>,
M: Into<Cow<'static, str>>,
{
self.summary = Some(summary.into());
self
@ -69,7 +69,7 @@ impl fmt::Display for MeliError {
impl Into<String> for MeliError {
fn into(self) -> String {
self.details
self.details.into()
}
}
@ -82,7 +82,7 @@ impl Error for MeliError {
impl From<io::Error> for MeliError {
#[inline]
fn from(kind: io::Error) -> MeliError {
MeliError::new(kind.description())
MeliError::new(kind.description().to_string())
}
}

View File

@ -1228,8 +1228,8 @@ pub fn save_draft(
context.accounts[account_cursor].save_special(bytes, folder_type, flags)
{
context.replies.push_back(UIEvent::Notification(
summary,
details,
summary.map(|s| s.into()),
details.into(),
Some(NotificationType::ERROR),
));
}

View File

@ -135,7 +135,7 @@ impl MailcapEntry {
}
match result {
None => Err(MeliError::new("Not found".to_string())),
None => Err(MeliError::new("Not found")),
Some(MailcapEntry {
command,
copiousoutput,