You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0277]: the trait bound `T: PartialSchema` is not satisfied
--> src/main.rs:3:14
|
3 | payload: T,
| ^ the trait `ComposeSchema` is not implemented for `T`, which is required by `T: PartialSchema`
|
= note: required for `T` to implement `PartialSchema`
help: consider restricting type parameter `T`
|
2 | struct Signed<T: utoipa::__dev::ComposeSchema> {
| ++++++++++++++++++++++++++++++
error[E0277]: the trait bound `T: ToSchema` is not satisfied
--> src/main.rs:3:14
|
3 | payload: T,
| ^ the trait `ToSchema` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
2 | struct Signed<T: utoipa::ToSchema> {
| ++++++++++++++++++
But the suggestion to define struct Signed<T: utoipa::ToSchema> would change the public API to require ToSchema for any Signed<T>. It would break other non-API-related code using Signed<T> on non-ToSchema types. My use case is to make utoipa dependency optional, so it's not possible to introduce breaking change on whether user enables utoipa feature.
I think a better solution would be generating the ToSchema bound on impl block, instead of requiring them on the struct definition. That is:
#[derive(ToSchema)]structSigned<T>{ .. }/// generates:impl<T:ToSchema/*<- added by derive-macro*/>ToSchemaforSigned<T>{ .. }
The text was updated successfully, but these errors were encountered:
I have generic types like this:
It fails to compile with:
But the suggestion to define
struct Signed<T: utoipa::ToSchema>
would change the public API to requireToSchema
for anySigned<T>
. It would break other non-API-related code usingSigned<T>
on non-ToSchema
types. My use case is to makeutoipa
dependency optional, so it's not possible to introduce breaking change on whether user enablesutoipa
feature.I think a better solution would be generating the
ToSchema
bound onimpl
block, instead of requiring them on the struct definition. That is:The text was updated successfully, but these errors were encountered: