Replace some turbofishes with type annotations
This commit is contained in:
parent
536a8aea1b
commit
1878e8aae0
@ -40,7 +40,7 @@ impl Parse for Meta {
|
||||
let ident = input.parse()?;
|
||||
|
||||
if input.peek(Token![=]) {
|
||||
let _ = input.parse::<Token![=]>();
|
||||
let _: Token![=] = input.parse()?;
|
||||
Ok(Meta::NameValue(MetaNameValue { name: ident, value: input.parse()? }))
|
||||
} else {
|
||||
Ok(Meta::Word(ident))
|
||||
|
@ -69,8 +69,8 @@ impl Parse for Api {
|
||||
impl Parse for Request {
|
||||
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||
let attributes = input.call(Attribute::parse_outer)?;
|
||||
let request_kw = input.parse::<kw::request>()?;
|
||||
input.parse::<Token![:]>()?;
|
||||
let request_kw: kw::request = input.parse()?;
|
||||
let _: Token![:] = input.parse()?;
|
||||
let fields;
|
||||
braced!(fields in input);
|
||||
|
||||
@ -201,8 +201,8 @@ impl Parse for Request {
|
||||
impl Parse for Response {
|
||||
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||
let attributes = input.call(Attribute::parse_outer)?;
|
||||
let response_kw = input.parse::<kw::response>()?;
|
||||
input.parse::<Token![:]>()?;
|
||||
let response_kw: kw::response = input.parse()?;
|
||||
let _: Token![:] = input.parse()?;
|
||||
let fields;
|
||||
braced!(fields in input);
|
||||
|
||||
|
@ -481,9 +481,9 @@ fn to_camel_case(name: &Ident) -> Ident {
|
||||
let span = name.span();
|
||||
let name = name.to_string();
|
||||
|
||||
let s = name
|
||||
let s: String = name
|
||||
.split('_')
|
||||
.map(|s| s.chars().next().unwrap().to_uppercase().to_string() + &s[1..])
|
||||
.collect::<String>();
|
||||
.collect();
|
||||
Ident::new(&s, span)
|
||||
}
|
||||
|
@ -44,14 +44,14 @@ impl Parse for EventMeta {
|
||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
||||
let lookahead = input.lookahead1();
|
||||
if lookahead.peek(Token![type]) {
|
||||
input.parse::<Token![type]>()?;
|
||||
input.parse::<Token![=]>()?;
|
||||
let _: Token![type] = input.parse()?;
|
||||
let _: Token![=] = input.parse()?;
|
||||
input.parse().map(EventMeta::Type)
|
||||
} else if lookahead.peek(kw::skip_redaction) {
|
||||
input.parse::<kw::skip_redaction>()?;
|
||||
let _: kw::skip_redaction = input.parse()?;
|
||||
Ok(EventMeta::SkipRedacted)
|
||||
} else if lookahead.peek(kw::custom_redacted) {
|
||||
input.parse::<kw::custom_redacted>()?;
|
||||
let _: kw::custom_redacted = input.parse()?;
|
||||
Ok(EventMeta::CustomRedacted)
|
||||
} else {
|
||||
Err(lookahead.error())
|
||||
|
@ -816,10 +816,10 @@ fn to_event_path(name: &LitStr, struct_name: &Ident, ruma_events: &TokenStream)
|
||||
let path: Vec<_> = name[2..].split('.').collect();
|
||||
|
||||
let event_str = path.last().unwrap();
|
||||
let event = event_str
|
||||
let event: String = event_str
|
||||
.split('_')
|
||||
.map(|s| s.chars().next().unwrap().to_uppercase().to_string() + &s[1..])
|
||||
.collect::<String>();
|
||||
.collect();
|
||||
|
||||
let path = path.iter().map(|s| Ident::new(s, span));
|
||||
|
||||
@ -869,10 +869,10 @@ fn to_event_content_path(
|
||||
let path: Vec<_> = name[2..].split('.').collect();
|
||||
|
||||
let event_str = path.last().unwrap();
|
||||
let event = event_str
|
||||
let event: String = event_str
|
||||
.split('_')
|
||||
.map(|s| s.chars().next().unwrap().to_uppercase().to_string() + &s[1..])
|
||||
.collect::<String>();
|
||||
.collect();
|
||||
|
||||
let content_str = match kind {
|
||||
EventKind::ToDevice => format_ident!("{}ToDeviceEventContent", event),
|
||||
@ -899,10 +899,10 @@ fn to_camel_case(name: &LitStr) -> syn::Result<Ident> {
|
||||
));
|
||||
}
|
||||
|
||||
let s = name[2..]
|
||||
let s: String = name[2..]
|
||||
.split(&['.', '_'] as &[char])
|
||||
.map(|s| s.chars().next().unwrap().to_uppercase().to_string() + &s[1..])
|
||||
.collect::<String>();
|
||||
.collect();
|
||||
|
||||
Ok(Ident::new(&s, span))
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ impl EventKind {
|
||||
|
||||
impl Parse for EventKind {
|
||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
||||
let ident = input.parse::<Ident>()?;
|
||||
let ident: Ident = input.parse()?;
|
||||
Ok(match ident.to_string().as_str() {
|
||||
"Basic" => EventKind::Basic,
|
||||
"EphemeralRoom" => EventKind::Ephemeral,
|
||||
@ -201,16 +201,16 @@ impl Parse for EventEnumInput {
|
||||
fn parse(input: ParseStream<'_>) -> parse::Result<Self> {
|
||||
let attrs = input.call(Attribute::parse_outer)?;
|
||||
// "name" field
|
||||
input.parse::<kw::kind>()?;
|
||||
input.parse::<Token![:]>()?;
|
||||
let _: kw::kind = input.parse()?;
|
||||
let _: Token![:] = input.parse()?;
|
||||
|
||||
// the name of our event enum
|
||||
let name = input.parse::<EventKind>()?;
|
||||
input.parse::<Token![,]>()?;
|
||||
let name: EventKind = input.parse()?;
|
||||
let _: Token![,] = input.parse()?;
|
||||
|
||||
// "events" field
|
||||
input.parse::<kw::events>()?;
|
||||
input.parse::<Token![:]>()?;
|
||||
let _: kw::events = input.parse()?;
|
||||
let _: Token![:] = input.parse()?;
|
||||
|
||||
// an array of event names `["m.room.whatever", ...]`
|
||||
let content;
|
||||
|
@ -18,7 +18,7 @@ struct Input {
|
||||
impl Parse for Input {
|
||||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
||||
let dollar_crate = input.parse()?;
|
||||
input.parse::<Token![,]>()?;
|
||||
let _: Token![,] = input.parse()?;
|
||||
let id = input.parse()?;
|
||||
|
||||
Ok(Self { dollar_crate, id })
|
||||
|
Loading…
x
Reference in New Issue
Block a user