Created
January 20, 2020 07:58
-
-
Save Gottox/fa0abf92249193278beb656597833d5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements | |
--> src/client.rs:95:76 | |
| | |
95 | let other_pages = iter(1 .. total_pages).then(move |n| cloned_self.page::<E>(n)); | |
| ^^^^ | |
| | |
note: first, the lifetime cannot outlive the lifetime `'_` as defined on the body at 95:55... | |
--> src/client.rs:95:55 | |
| | |
95 | let other_pages = iter(1 .. total_pages).then(move |n| cloned_self.page::<E>(n)); | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
note: ...so that closure can access `cloned_self` | |
--> src/client.rs:95:64 | |
| | |
95 | let other_pages = iter(1 .. total_pages).then(move |n| cloned_self.page::<E>(n)); | |
| ^^^^^^^^^^^ | |
note: but, the lifetime must be valid for the method call at 95:27... | |
--> src/client.rs:95:27 | |
| | |
95 | let other_pages = iter(1 .. total_pages).then(move |n| cloned_self.page::<E>(n)); | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
note: ...so type `futures_util::stream::stream::then::Then<futures_util::stream::iter::Iter<std::ops::Range<usize>>, impl core::future::future::Future, [closure@src/client.rs:95:55: 95:88 cloned_self:client::Client]>` of expression is valid during the expression | |
--> src/client.rs:95:27 | |
| | |
95 | let other_pages = iter(1 .. total_pages).then(move |n| cloned_self.page::<E>(n)); | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
error: aborting due to previous error | |
For more information about this error, try `rustc --explain E0495`. | |
error: could not compile `lexoffice`. | |
To learn more, run the command again with --verbose. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
async fn stream<E>( | |
&self, | |
) -> Box<dyn Stream<Item = Result<Page<E>, Box<dyn Error>>>> | |
where | |
E: PaginationEndpoint + DeserializeOwned + 'static, | |
{ | |
use std::iter::once; | |
use futures::stream::iter; | |
let first_page = match self.page::<E>(0).await { | |
Ok(x) => x, | |
x => return Box::new(iter(once(x))), | |
}; | |
let total_pages = first_page.total_pages; | |
let cloned_self = self.clone(); | |
let other_pages = iter(1 .. total_pages).then(move |n| cloned_self.page::<E>(n)); | |
Box::new(iter(once(Ok(first_page))).chain(other_pages)) | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 18 represents Line 95 in the error message.