Use Outgoing trait in ruma_api_lifetime tests
This commit is contained in:
parent
80237d6dd1
commit
588a6035f0
@ -160,9 +160,9 @@ impl ToTokens for Api {
|
||||
{
|
||||
let body_lifetimes = if self.request.has_body_lifetimes() {
|
||||
// duplicate the anonymous lifetime as many times as needed
|
||||
let anon = quote! { '_, };
|
||||
let lifetimes = vec![&anon].repeat(self.request.body_lifetime_count());
|
||||
quote! { < #( #lifetimes )* >}
|
||||
let lifetimes =
|
||||
std::iter::repeat(quote! { '_ }).take(self.request.body_lifetime_count());
|
||||
quote! { < #( #lifetimes, )* >}
|
||||
} else {
|
||||
TokenStream::new()
|
||||
};
|
||||
@ -200,9 +200,9 @@ impl ToTokens for Api {
|
||||
{
|
||||
let body_lifetimes = if self.response.has_body_lifetimes() {
|
||||
// duplicate the anonymous lifetime as many times as needed
|
||||
let anon = quote! { '_, };
|
||||
let lifetimes = vec![&anon].repeat(self.response.body_lifetime_count());
|
||||
quote! { < #( #lifetimes )* >}
|
||||
let lifetimes =
|
||||
std::iter::repeat(quote! { '_ }).take(self.response.body_lifetime_count());
|
||||
quote! { < #( #lifetimes, )* >}
|
||||
} else {
|
||||
TokenStream::new()
|
||||
};
|
||||
|
@ -1,5 +1,12 @@
|
||||
use ruma_identifiers::{RoomAliasId, RoomId};
|
||||
|
||||
#[allow(unused)]
|
||||
#[derive(Copy, Clone, Debug, ruma_api::Outgoing, serde::Serialize)]
|
||||
pub struct OtherThing<'t> {
|
||||
some: &'t str,
|
||||
t: &'t [u8],
|
||||
}
|
||||
|
||||
mod empty_response {
|
||||
use super::*;
|
||||
|
||||
@ -54,18 +61,7 @@ mod nested_types {
|
||||
}
|
||||
|
||||
mod full_request_response {
|
||||
#[allow(unused)]
|
||||
#[derive(Copy, Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct OtherThing<'t> {
|
||||
some: &'t str,
|
||||
t: &'t [u8],
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct IncomingOtherThing {
|
||||
some: String,
|
||||
t: Vec<u8>,
|
||||
}
|
||||
use super::*;
|
||||
|
||||
ruma_api::ruma_api! {
|
||||
metadata: {
|
||||
@ -97,18 +93,7 @@ mod full_request_response {
|
||||
}
|
||||
|
||||
mod full_request_response_with_query_map {
|
||||
#[allow(unused)]
|
||||
#[derive(Copy, Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct OtherThing<'t> {
|
||||
some: &'t str,
|
||||
t: &'t [u8],
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct IncomingOtherThing {
|
||||
some: String,
|
||||
t: Vec<u8>,
|
||||
}
|
||||
use super::*;
|
||||
|
||||
ruma_api::ruma_api! {
|
||||
metadata: {
|
||||
@ -122,7 +107,7 @@ mod full_request_response_with_query_map {
|
||||
|
||||
request: {
|
||||
#[ruma_api(query_map)]
|
||||
// pub abc: &'a [(&'a str, &'a str)], // TODO This does not impl Deserialize
|
||||
// pub abc: &'a [(&'a str, &'a str)], // TODO handle this use case
|
||||
pub abc: Vec<(String, String)>,
|
||||
#[ruma_api(path)]
|
||||
pub thing: &'a str,
|
||||
|
Loading…
x
Reference in New Issue
Block a user