Skip to content

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

@Ploppz

Description

@Ploppz

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions