#320·paperclip

Add support for `Box<T>`

Author: ManevilleFCreated May 5, 2021Updated Feb 21, 2025

If I have the following struct:

#[derive(Debug, Serialize, Deserialize, Apiv2Schema)]
pub struct Foo {
     pub elements: Vec<Box<Foo>>,
}

I get the the following error:

9 | #[derive(Debug, Serialize, Deserialize, Apiv2Schema)]
  |                                         ^^^^^^^^^^^ function or associated item cannot be called on `std::vec::Vec<std::boxed::Box<Foo>>` due to unsatisfied trait bounds
  |
  = note: the following trait bounds were not satisfied:
          `&std::vec::Vec<std::boxed::Box<Foo>>: paperclip::v2::schema::TypedData`
          which is required by `&std::vec::Vec<std::boxed::Box<Foo>>: paperclip::v2::schema::Apiv2Schema`
          `&mut std::vec::Vec<std::boxed::Box<Foo>>: paperclip::v2::schema::TypedData`
          which is required by `&mut std::vec::Vec<std::boxed::Box<Foo>>: paperclip::v2::schema::Apiv2Schema`
  = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

I think the issue is coming from the Box part as Vec<T> is usually correctly handled.

I will try to look into the core code to see if I can open a pull request but if anyone knows how to fix this I'll gladly accept