1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-26 06:57:43 +02:00

Various refactorings (#2281)

Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
Igor Aleksanov
2021-06-26 18:33:43 +04:00
committed by GitHub
parent 5eba95b731
commit 262c6bc828
30 changed files with 98 additions and 121 deletions

View File

@ -6,7 +6,7 @@ use std::convert::TryFrom;
use proc_macro::TokenStream;
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::{format_ident, quote, ToTokens, TokenStreamExt};
use syn::{parse_macro_input, AttributeArgs, Ident, NestedMeta};
use syn::{parse_macro_input, AttributeArgs, Ident, LitStr, NestedMeta};
enum ResourceType {
Async,
@ -227,8 +227,7 @@ impl Route {
format!(
r#"invalid service definition, expected #[{}("<some path>")]"#,
method
.map(|it| it.as_str())
.unwrap_or("route")
.map_or("route", |it| it.as_str())
.to_ascii_lowercase()
),
));
@ -298,7 +297,7 @@ impl ToTokens for Route {
} = self;
let resource_name = resource_name
.as_ref()
.map_or_else(|| name.to_string(), |n| n.value());
.map_or_else(|| name.to_string(), LitStr::value);
let method_guards = {
let mut others = methods.iter();
// unwrapping since length is checked to be at least one