mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-23 15:19:36 +01:00
Remove unnecessary collect
This commit is contained in:
parent
9a2e39ea01
commit
99685f3dcc
1 changed files with 27 additions and 31 deletions
|
@ -50,9 +50,7 @@ impl CommandAttrs {
|
||||||
pub fn from_attributes(attributes: &[Attribute]) -> Result<Self> {
|
pub fn from_attributes(attributes: &[Attribute]) -> Result<Self> {
|
||||||
use CommandAttrKind::*;
|
use CommandAttrKind::*;
|
||||||
// Convert the `doc` attribute into `command(description = "...")`
|
// Convert the `doc` attribute into `command(description = "...")`
|
||||||
let attributes = attributes
|
let attributes = attributes.iter().map(|attr| {
|
||||||
.iter()
|
|
||||||
.map(|attr| {
|
|
||||||
if attr.path.is_ident("doc") {
|
if attr.path.is_ident("doc") {
|
||||||
// Extract the token literal from the doc attribute.
|
// Extract the token literal from the doc attribute.
|
||||||
let description = attr
|
let description = attr
|
||||||
|
@ -73,16 +71,14 @@ impl CommandAttrs {
|
||||||
let attr = Attribute::parse_outer
|
let attr = Attribute::parse_outer
|
||||||
.parse2(quote_spanned!(sp => #[command(description = #description)]))
|
.parse2(quote_spanned!(sp => #[command(description = #description)]))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// SAFETY: `parse_outer` always returns a single attribute.
|
|
||||||
attr.into_iter().next().unwrap()
|
attr.into_iter().next().unwrap()
|
||||||
} else {
|
} else {
|
||||||
attr.clone()
|
attr.clone()
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
fold_attrs(
|
fold_attrs(
|
||||||
attributes.iter(),
|
attributes,
|
||||||
is_command_attribute,
|
is_command_attribute,
|
||||||
CommandAttr::parse,
|
CommandAttr::parse,
|
||||||
Self {
|
Self {
|
||||||
|
|
Loading…
Add table
Reference in a new issue