netwo-io / apistos

Actix-web wrapper for automatic OpenAPI 3.0 documentation generation.
MIT License
124 stars 3 forks source link

I have to `use std::iter::FromIterator;` in code calling the api_operation macro #121

Open Ploppz opened 1 month ago

Ploppz commented 1 month ago

I'm just starting to wrap my API in this library. I got this error

error[E0599]: no function or associated item named `from_iter` found for struct `BTreeMap` in the current scope
    --> orchestrator/src/endpoints/measurements.rs:74:1
     |
74   | #[api_operation(summary = "Get an element from the todo list")]
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `BTreeMap<_, _, _>`
     |
note: if you're trying to build a new `BTreeMap<_, _, _>` consider using one of the following associated functions:
      BTreeMap::<K, V>::new
      BTreeMap::<K, V, A>::new_in
      BTreeMap::<K, V, A>::bulk_build_from_sorted_iter
    --> /home/ploppz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/collections/btree/map.rs:629:5
     |
629  |       pub const fn new() -> BTreeMap<K, V> {
     |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
674  |       pub const fn new_in(alloc: A) -> BTreeMap<K, V, A> {
     |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
1472 | /     pub(crate) fn bulk_build_from_sorted_iter<I>(iter: I, alloc: A) -> Self
1473 | |     where
1474 | |         K: Ord,
1475 | |         I: IntoIterator<Item = (K, V)>,
     | |_______________________________________^
     = help: items from traits can only be used if the trait is in scope
     = note: this error originates in the attribute macro `api_operation` (in Nightly builds, run with -Z macro-backtrace for more info)
help: trait `FromIterator` which provides `from_iter` is implemented but not in scope; perhaps you want to import it
     |
1    + use std::iter::FromIterator;
     |

Just want to suggest to use fully qualified syntax to use FromIterator::from_iter for example so that library users don't have to import that trait.

rlebran commented 1 month ago

Hi,

Sorry for the delay, I'm having a look.

rlebran commented 1 month ago

Is it possible to provide a minimal reproduction example please ? I'm currently unable to reproduce.