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() {
|
let body_lifetimes = if self.request.has_body_lifetimes() {
|
||||||
// duplicate the anonymous lifetime as many times as needed
|
// duplicate the anonymous lifetime as many times as needed
|
||||||
let anon = quote! { '_, };
|
let lifetimes =
|
||||||
let lifetimes = vec![&anon].repeat(self.request.body_lifetime_count());
|
std::iter::repeat(quote! { '_ }).take(self.request.body_lifetime_count());
|
||||||
quote! { < #( #lifetimes )* >}
|
quote! { < #( #lifetimes, )* >}
|
||||||
} else {
|
} else {
|
||||||
TokenStream::new()
|
TokenStream::new()
|
||||||
};
|
};
|
||||||
@ -200,9 +200,9 @@ impl ToTokens for Api {
|
|||||||
{
|
{
|
||||||
let body_lifetimes = if self.response.has_body_lifetimes() {
|
let body_lifetimes = if self.response.has_body_lifetimes() {
|
||||||
// duplicate the anonymous lifetime as many times as needed
|
// duplicate the anonymous lifetime as many times as needed
|
||||||
let anon = quote! { '_, };
|
let lifetimes =
|
||||||
let lifetimes = vec![&anon].repeat(self.response.body_lifetime_count());
|
std::iter::repeat(quote! { '_ }).take(self.response.body_lifetime_count());
|
||||||
quote! { < #( #lifetimes )* >}
|
quote! { < #( #lifetimes, )* >}
|
||||||
} else {
|
} else {
|
||||||
TokenStream::new()
|
TokenStream::new()
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
use ruma_identifiers::{RoomAliasId, RoomId};
|
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 {
|
mod empty_response {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@ -54,18 +61,7 @@ mod nested_types {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod full_request_response {
|
mod full_request_response {
|
||||||
#[allow(unused)]
|
use super::*;
|
||||||
#[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>,
|
|
||||||
}
|
|
||||||
|
|
||||||
ruma_api::ruma_api! {
|
ruma_api::ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -97,18 +93,7 @@ mod full_request_response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod full_request_response_with_query_map {
|
mod full_request_response_with_query_map {
|
||||||
#[allow(unused)]
|
use super::*;
|
||||||
#[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>,
|
|
||||||
}
|
|
||||||
|
|
||||||
ruma_api::ruma_api! {
|
ruma_api::ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -122,7 +107,7 @@ mod full_request_response_with_query_map {
|
|||||||
|
|
||||||
request: {
|
request: {
|
||||||
#[ruma_api(query_map)]
|
#[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)>,
|
pub abc: Vec<(String, String)>,
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub thing: &'a str,
|
pub thing: &'a str,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user