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