Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions conjure-codegen/src/aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,9 @@ pub fn generate(ctx: &Context, def: &AliasDefinition) -> TokenStream {
}

if ctx.is_double(def.alias()) {
derives.push("conjure_object::private::Educe");
type_attrs.push(quote!(#[educe(PartialEq, Eq, PartialOrd, Ord, Hash)]));
field_attrs.push(quote! {
#[educe(
PartialEq(method(conjure_object::private::DoubleOps::eq)),
Ord(method(conjure_object::private::DoubleOps::cmp)),
Hash(method(conjure_object::private::DoubleOps::hash)),
)]
})
derives.push("conjure_object::private::DeriveWith");
type_attrs.push(quote!(#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]));
field_attrs.push(quote!(#[derive_with(with = conjure_object::private::DoubleWrapper)]));
} else {
derives.push("PartialEq");
derives.push("Eq");
Expand All @@ -59,7 +53,7 @@ pub fn generate(ctx: &Context, def: &AliasDefinition) -> TokenStream {
}

let derives = derives.iter().map(|s| s.parse::<TokenStream>().unwrap());
// The derive attr has to be before the educe attr, so insert rather than push
// The derive attr has to be before the derive_with attr, so insert rather than push
type_attrs.insert(0, quote!(#[derive(#(#derives),*)]));

let display = if ctx.is_display(def.alias()) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions conjure-codegen/src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ pub fn generate(ctx: &Context, base_module: BaseModule, def: &ObjectDefinition)
];

if def.fields().iter().any(|v| ctx.has_double(v.type_())) {
derives.push("conjure_object::private::Educe");
type_attrs.push(quote!(#[educe(PartialEq, Eq, PartialOrd, Ord, Hash)]));
derives.push("conjure_object::private::DeriveWith");
type_attrs.push(quote!(#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]));
} else {
derives.push("PartialEq");
derives.push("Eq");
Expand All @@ -44,19 +44,15 @@ pub fn generate(ctx: &Context, base_module: BaseModule, def: &ObjectDefinition)
}

let derives = derives.iter().map(|s| s.parse::<TokenStream>().unwrap());
// The derive attr has to be before the educe attr, so insert rather than push
// The derive attr has to be before the derive_with attr, so insert rather than push
type_attrs.insert(0, quote!(#[derive(#(#derives),*)]));

let field_attrs = def.fields().iter().map(|s| {
let builder_attr = field_builder_attr(ctx, base_module, def, s);
let serde_attr = serde_field_attr(ctx, def, s);
let educe_attr = if ctx.is_double(s.type_()) {
quote! {
#[educe(
PartialEq(method(conjure_object::private::DoubleOps::eq)),
Ord(method(conjure_object::private::DoubleOps::cmp)),
Hash(method(conjure_object::private::DoubleOps::hash)),
)]
#[derive_with(with = conjure_object::private::DoubleWrapper)]
}
} else {
quote!()
Expand Down
12 changes: 4 additions & 8 deletions conjure-codegen/src/unions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ fn generate_enum(ctx: &Context, def: &UnionDefinition) -> TokenStream {
let mut type_attrs = vec![];
let mut derives = vec!["Debug", "Clone"];
if def.union_().iter().any(|v| ctx.has_double(v.type_())) {
derives.push("conjure_object::private::Educe");
type_attrs.push(quote!(#[educe(PartialEq, Eq, PartialOrd, Ord, Hash)]));
derives.push("conjure_object::private::DeriveWith");
type_attrs.push(quote!(#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]));
} else {
derives.push("PartialEq");
derives.push("Eq");
Expand All @@ -70,7 +70,7 @@ fn generate_enum(ctx: &Context, def: &UnionDefinition) -> TokenStream {
derives.push("Hash");
}
let derives = derives.iter().map(|s| s.parse::<TokenStream>().unwrap());
// The derive attr has to be before the educe attr, so insert rather than push
// The derive attr has to be before the derive_with attr, so insert rather than push
type_attrs.insert(0, quote!(#[derive(#(#derives),*)]));

let docs = def.union_().iter().map(|f| ctx.docs(f.docs()));
Expand All @@ -84,11 +84,7 @@ fn generate_enum(ctx: &Context, def: &UnionDefinition) -> TokenStream {
.map(|f| {
let attr = if ctx.is_double(f.type_()) {
quote! {
#[educe(
PartialEq(method(conjure_object::private::DoubleOps::eq)),
Ord(method(conjure_object::private::DoubleOps::cmp)),
Hash(method(conjure_object::private::DoubleOps::hash)),
)]
#[derive_with(with = conjure_object::private::DoubleWrapper)]
}
} else {
quote!()
Expand Down
4 changes: 2 additions & 2 deletions conjure-http/src/private/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ where
Request::new(AsyncRequestBody::Empty)
}

pub fn encode_serializable_request<T, S>(body: &T) -> Request<RequestBody<S>>
pub fn encode_serializable_request<T, S>(body: &'_ T) -> Request<RequestBody<'_, S>>
where
T: Serialize,
{
inner_encode_serializable_request(body, RequestBody::Fixed)
}

pub fn async_encode_serializable_request<T, S>(body: &T) -> Request<AsyncRequestBody<S>>
pub fn async_encode_serializable_request<T, S>(body: &'_ T) -> Request<AsyncRequestBody<'_, S>>
where
T: Serialize,
{
Expand Down
Loading