Fix new clippy lints (1.75)
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>pull/335/head
parent
808aa4942d
commit
f63774fa6d
|
@ -427,7 +427,7 @@ impl Composer {
|
|||
)
|
||||
.as_ref()
|
||||
.map(|s| s.as_str()),
|
||||
envelope.from().get(0),
|
||||
envelope.from().first(),
|
||||
envelope.date(),
|
||||
*account_settings!(
|
||||
context[ret.account_hash]
|
||||
|
@ -1670,7 +1670,7 @@ impl Component for Composer {
|
|||
)
|
||||
.map_err(|_err| -> Error { "No valid sender address in `From:`".into() })
|
||||
.and_then(|(_, list)| {
|
||||
list.get(0)
|
||||
list.first()
|
||||
.cloned()
|
||||
.ok_or_else(|| "No valid sender address in `From:`".into())
|
||||
})
|
||||
|
@ -1711,7 +1711,7 @@ impl Component for Composer {
|
|||
)
|
||||
.map_err(|_err| -> Error { "No valid recipient addresses in `To:`".into() })
|
||||
.and_then(|(_, list)| {
|
||||
list.get(0)
|
||||
list.first()
|
||||
.cloned()
|
||||
.ok_or_else(|| "No valid recipient addresses in `To:`".into())
|
||||
})
|
||||
|
|
|
@ -177,7 +177,7 @@ impl Component for KeySelection {
|
|||
move |id: ComponentId, results: &[melib::gpgme::Key]| {
|
||||
Some(UIEvent::FinishedUIDialog(
|
||||
id,
|
||||
Box::new(results.get(0).cloned()),
|
||||
Box::new(results.first().cloned()),
|
||||
))
|
||||
},
|
||||
)),
|
||||
|
|
|
@ -719,7 +719,7 @@ pub trait MailListingTrait: ListingTrait {
|
|||
format.append(
|
||||
&mut file,
|
||||
bytes.as_slice(),
|
||||
env.from().get(0),
|
||||
env.from().first(),
|
||||
Some(env.date()),
|
||||
(env.flags(), tags),
|
||||
MboxMetadata::CClient,
|
||||
|
@ -736,7 +736,7 @@ pub trait MailListingTrait: ListingTrait {
|
|||
format.append(
|
||||
&mut file,
|
||||
bytes.as_slice(),
|
||||
env.from().get(0),
|
||||
env.from().first(),
|
||||
Some(env.date()),
|
||||
(env.flags(), tags),
|
||||
MboxMetadata::CClient,
|
||||
|
|
|
@ -499,7 +499,7 @@ impl Component for MailView {
|
|||
move |id: ComponentId, result: &[Option<PendingReplyAction>]| {
|
||||
Some(UIEvent::FinishedUIDialog(
|
||||
id,
|
||||
Box::new(result.get(0).cloned().flatten()),
|
||||
Box::new(result.first().cloned().flatten()),
|
||||
))
|
||||
},
|
||||
)),
|
||||
|
|
|
@ -865,7 +865,7 @@ impl ThreadView {
|
|||
|
||||
impl std::fmt::Display for ThreadView {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
if let Some(e) = self.entries.get(0) {
|
||||
if let Some(e) = self.entries.first() {
|
||||
e.mailview.fmt(fmt)
|
||||
} else {
|
||||
write!(fmt, "view thread")
|
||||
|
|
|
@ -866,7 +866,7 @@ impl Tabbed {
|
|||
help_view: HelpView {
|
||||
content: Screen::<Virtual>::new(),
|
||||
curr_views: children
|
||||
.get(0)
|
||||
.first()
|
||||
.map(|c| c.shortcuts(context))
|
||||
.unwrap_or_default(),
|
||||
cursor: (0, 0),
|
||||
|
|
|
@ -356,7 +356,7 @@ impl Address {
|
|||
/// Formats a slice of `Address`es with their `Address::display` method,
|
||||
/// separated by comma or `separator` if passed.
|
||||
pub fn display_slice(slice: &[Self]) -> String {
|
||||
match slice.get(0) {
|
||||
match slice.first() {
|
||||
None => String::new(),
|
||||
Some(f) if slice.len() == 1 => f.display().to_string(),
|
||||
Some(_) => slice
|
||||
|
@ -370,7 +370,7 @@ impl Address {
|
|||
/// Formats a slice of `Address`es with their `Address::display_name`
|
||||
/// method, separated by comma or `separator` if passed.
|
||||
pub fn display_name_slice(slice: &[Self]) -> String {
|
||||
match slice.get(0) {
|
||||
match slice.first() {
|
||||
None => String::new(),
|
||||
Some(f) if slice.len() == 1 => f.display_name().to_string(),
|
||||
Some(_) => slice
|
||||
|
|
|
@ -264,7 +264,7 @@ impl std::convert::From<EmailObject> for crate::Envelope {
|
|||
env.set_date(std::mem::take(sent_at).as_bytes());
|
||||
}
|
||||
|
||||
if let Some(v) = t.message_id.get(0) {
|
||||
if let Some(v) = t.message_id.first() {
|
||||
env.set_message_id(v.as_bytes());
|
||||
}
|
||||
if let Some(ref in_reply_to) = t.in_reply_to {
|
||||
|
|
|
@ -45,6 +45,13 @@
|
|||
clippy::case_sensitive_file_extension_comparisons,
|
||||
//clippy::cast_lossless,
|
||||
//clippy::cast_ptr_alignment,
|
||||
clippy::large_futures,
|
||||
clippy::waker_clone_wake,
|
||||
clippy::unused_enumerate_index,
|
||||
clippy::unnecessary_fallible_conversions,
|
||||
clippy::struct_field_names,
|
||||
clippy::manual_hash_one,
|
||||
clippy::into_iter_without_iter,
|
||||
)]
|
||||
#![allow(
|
||||
clippy::option_if_let_else,
|
||||
|
|
|
@ -85,6 +85,15 @@ impl<'q> Thread<'q> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'q> IntoIterator for &'q Thread<'q> {
|
||||
type IntoIter = MessageIterator<'q>;
|
||||
type Item = Message<'q>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Thread<'_> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
|
|
|
@ -124,8 +124,8 @@ enum LocaleCategory {
|
|||
struct Locale {
|
||||
mask: LocaleCategoryMask,
|
||||
category: LocaleCategory,
|
||||
new_locale: libc::locale_t,
|
||||
old_locale: libc::locale_t,
|
||||
new: libc::locale_t,
|
||||
old: libc::locale_t,
|
||||
}
|
||||
|
||||
#[cfg(target_os = "netbsd")]
|
||||
|
@ -133,19 +133,19 @@ struct Locale {
|
|||
struct Locale {
|
||||
mask: LocaleCategoryMask,
|
||||
category: LocaleCategory,
|
||||
old_locale: *const std::os::raw::c_char,
|
||||
old: *const std::os::raw::c_char,
|
||||
}
|
||||
|
||||
impl Drop for Locale {
|
||||
fn drop(&mut self) {
|
||||
#[cfg(not(target_os = "netbsd"))]
|
||||
unsafe {
|
||||
let _ = libc::uselocale(self.old_locale);
|
||||
libc::freelocale(self.new_locale);
|
||||
let _ = libc::uselocale(self.old);
|
||||
libc::freelocale(self.new);
|
||||
}
|
||||
#[cfg(target_os = "netbsd")]
|
||||
unsafe {
|
||||
let _ = libc::setlocale(self.category as c_int, self.old_locale);
|
||||
let _ = libc::setlocale(self.category as c_int, self.old);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,22 +160,23 @@ impl Locale {
|
|||
locale: *const std::os::raw::c_char,
|
||||
base: libc::locale_t,
|
||||
) -> Result<Self> {
|
||||
let new_locale = unsafe { libc::newlocale(mask as c_int, locale, base) };
|
||||
if new_locale.is_null() {
|
||||
let new = unsafe { libc::newlocale(mask as c_int, locale, base) };
|
||||
if new.is_null() {
|
||||
return Err(nix::Error::last().into());
|
||||
}
|
||||
let old_locale = unsafe { libc::uselocale(new_locale) };
|
||||
if old_locale.is_null() {
|
||||
unsafe { libc::freelocale(new_locale) };
|
||||
let old = unsafe { libc::uselocale(new) };
|
||||
if old.is_null() {
|
||||
unsafe { libc::freelocale(new) };
|
||||
return Err(nix::Error::last().into());
|
||||
}
|
||||
Ok(Self {
|
||||
mask,
|
||||
category,
|
||||
new_locale,
|
||||
old_locale,
|
||||
new,
|
||||
old,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(target_os = "netbsd")]
|
||||
fn new(
|
||||
mask: LocaleCategoryMask,
|
||||
|
@ -183,18 +184,18 @@ impl Locale {
|
|||
locale: *const std::os::raw::c_char,
|
||||
_base: libc::locale_t,
|
||||
) -> Result<Self> {
|
||||
let old_locale = unsafe { libc::setlocale(category as c_int, std::ptr::null_mut()) };
|
||||
if old_locale.is_null() {
|
||||
let old = unsafe { libc::setlocale(category as c_int, std::ptr::null_mut()) };
|
||||
if old.is_null() {
|
||||
return Err(nix::Error::last().into());
|
||||
}
|
||||
let new_locale = unsafe { libc::setlocale(category as c_int, locale) };
|
||||
if new_locale.is_null() {
|
||||
let new = unsafe { libc::setlocale(category as c_int, locale) };
|
||||
if new.is_null() {
|
||||
return Err(nix::Error::last().into());
|
||||
}
|
||||
Ok(Locale {
|
||||
mask,
|
||||
category,
|
||||
old_locale,
|
||||
old,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,11 +348,8 @@ where
|
|||
P: Parser<'a, R>,
|
||||
{
|
||||
move |input| {
|
||||
pre.parse(input).and_then(|(last_input, _)| {
|
||||
parser
|
||||
.parse(last_input)
|
||||
.map(|(rest, result)| (rest, result))
|
||||
})
|
||||
pre.parse(input)
|
||||
.and_then(|(last_input, _)| parser.parse(last_input))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue