api-macros: Small formatting fixes

This commit is contained in:
Jonas Platte 2021-04-09 19:29:29 +02:00
parent 455eb31c74
commit 20124cb215
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -541,7 +541,10 @@ impl Request {
self, self,
base_url: &::std::primitive::str, base_url: &::std::primitive::str,
access_token: ::std::option::Option<&str>, access_token: ::std::option::Option<&str>,
) -> ::std::result::Result<#http::Request<Vec<u8>>, #ruma_api::error::IntoHttpError> { ) -> ::std::result::Result<
#http::Request<Vec<u8>>,
#ruma_api::error::IntoHttpError,
> {
let metadata = self::METADATA; let metadata = self::METADATA;
let mut req_builder = #http::Request::builder() let mut req_builder = #http::Request::builder()
@ -686,20 +689,20 @@ impl Request {
let field_name = field.ident.as_ref().expect("expected field to have identifier"); let field_name = field.ident.as_ref().expect("expected field to have identifier");
quote!({ quote!({
// This function exists so that the compiler will throw an // This function exists so that the compiler will throw an error when the type of
// error when the type of the field with the query_map // the field with the query_map attribute doesn't implement
// attribute doesn't implement IntoIterator<Item = (String, String)> // `IntoIterator<Item = (String, String)>`.
// //
// This is necessary because the ruma_serde::urlencoded::to_string // This is necessary because the `ruma_serde::urlencoded::to_string` call will
// call will result in a runtime error when the type cannot be // result in a runtime error when the type cannot be encoded as a list key-value
// encoded as a list key-value pairs (?key1=value1&key2=value2) // pairs (?key1=value1&key2=value2).
// //
// By asserting that it implements the iterator trait, we can // By asserting that it implements the iterator trait, we can ensure that it won't
// ensure that it won't fail. // fail.
fn assert_trait_impl<T>(_: &T) fn assert_trait_impl<T>(_: &T)
where where
T: ::std::iter::IntoIterator< T: ::std::iter::IntoIterator<
Item = (::std::string::String, ::std::string::String) Item = (::std::string::String, ::std::string::String),
>, >,
{} {}
@ -729,14 +732,13 @@ impl Request {
} }
} }
/// The first item in the tuple generates code for the request path from /// The first item in the tuple generates code for the request path from the `Metadata` and
/// the `Metadata` and `Request` structs. The second item in the returned tuple /// `Request` structs. The second item in the returned tuple is the code to generate a Request
/// is the code to generate a Request struct field created from any segments /// struct field created from any segments of the path that start with ":".
/// of the path that start with ":".
/// ///
/// The first `TokenStream` returned is the constructed url path. The second `TokenStream` is /// The first `TokenStream` returned is the constructed url path. The second `TokenStream` is
/// used for implementing `TryFrom<http::Request<Vec<u8>>>`, from path strings deserialized to Ruma /// used for implementing `TryFrom<http::Request<Vec<u8>>>`, from path strings deserialized to
/// types. /// Ruma types.
pub(crate) fn path_string_and_parse( pub(crate) fn path_string_and_parse(
&self, &self,
metadata: &Metadata, metadata: &Metadata,