Remove unnecessary collect

This commit is contained in:
TheAwiteb 2023-03-02 15:57:43 +03:00
parent 9a2e39ea01
commit 99685f3dcc
No known key found for this signature in database
GPG key ID: ABF818BD15DC2D34

View file

@ -50,9 +50,7 @@ impl CommandAttrs {
pub fn from_attributes(attributes: &[Attribute]) -> Result<Self> {
use CommandAttrKind::*;
// Convert the `doc` attribute into `command(description = "...")`
let attributes = attributes
.iter()
.map(|attr| {
let attributes = attributes.iter().map(|attr| {
if attr.path.is_ident("doc") {
// Extract the token literal from the doc attribute.
let description = attr
@ -73,16 +71,14 @@ impl CommandAttrs {
let attr = Attribute::parse_outer
.parse2(quote_spanned!(sp => #[command(description = #description)]))
.unwrap();
// SAFETY: `parse_outer` always returns a single attribute.
attr.into_iter().next().unwrap()
} else {
attr.clone()
}
})
.collect::<Vec<_>>();
});
fold_attrs(
attributes.iter(),
attributes,
is_command_attribute,
CommandAttr::parse,
Self {