ctaggart / autorust_openapi

openapi schema serialization for rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boxing ReferenceOr<Schema>

ctaggart opened this issue · comments

copying here from glademiller/openapiv3#22:

Great job on this project btw! I've been trying to bring some openapi v2 bindings as close to this as I can at https://github.com/ctaggart/autorust_openapi. I'm opening this issue because I'm a little confused by boxing in Rust. The last couple of days, I've been running into issues like this:

image

I noticed that it is being done a couple of different ways in this openapiv3:

  • Box<ReferenceOr<Schema>>
  • ReferenceOr<Box<Schema>>

image

This doc says:

Because Boxes implement the Deref<Target=T>, you can use boxed values just like the value they contain.

I've thought about switching everything to Box<ReferenceOr<Schema>> or maybe implementing Deref. I'm not sure if either will work or one is better than the other. Thoughts?