Skip to content

Instantly share code, notes, and snippets.

@jimmycuadra jimmycuadra/compiler_output.txt Secret
Created Feb 20, 2019

Embed
What would you like to do?
Stream does not impl Future?
cargo test --test echo
Compiling rustin v0.1.0 (/rustin)
error[E0277]: the trait bound `dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin: core::future::future::Future` is not satisfied
--> tests/echo.rs:16:10
|
16 | .then(|result| match result {
| ^^^^ the trait `core::future::future::Future` is not implemented for `dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin`
|
= note: required because of the requirements on the impl of `core::future::future::Future` for `std::boxed::Box<dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin>`
error[E0599]: no method named `into_stream` found for type `futures_util::future::then::Then<std::boxed::Box<dyn core::future::future::Future<Output=std::result::Result<std::option::Option<std::string::String>, <S as rustin::store::Store>::Error>> + std::marker::Unpin>, std::boxed::Box<dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin>, [closure@tests/echo.rs:16:15: 27:10 message:_, store:_, id:_]>` in the current scope
--> tests/echo.rs:28:10
|
28 | .into_stream()
| ^^^^^^^^^^^
|
= note: the method `into_stream` exists but the following trait bounds were not satisfied:
`&futures_util::future::then::Then<std::boxed::Box<dyn core::future::future::Future<Output=std::result::Result<std::option::Option<std::string::String>, <S as rustin::store::Store>::Error>> + std::marker::Unpin>, std::boxed::Box<dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin>, [closure@tests/echo.rs:16:15: 27:10 message:_, store:_, id:_]> : futures_util::future::FutureExt`
`&futures_util::future::then::Then<std::boxed::Box<dyn core::future::future::Future<Output=std::result::Result<std::option::Option<std::string::String>, <S as rustin::store::Store>::Error>> + std::marker::Unpin>, std::boxed::Box<dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin>, [closure@tests/echo.rs:16:15: 27:10 message:_, store:_, id:_]> : futures_util::try_stream::TryStreamExt`
`&mut futures_util::future::then::Then<std::boxed::Box<dyn core::future::future::Future<Output=std::result::Result<std::option::Option<std::string::String>, <S as rustin::store::Store>::Error>> + std::marker::Unpin>, std::boxed::Box<dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin>, [closure@tests/echo.rs:16:15: 27:10 message:_, store:_, id:_]> : futures_util::future::FutureExt`
`&mut futures_util::future::then::Then<std::boxed::Box<dyn core::future::future::Future<Output=std::result::Result<std::option::Option<std::string::String>, <S as rustin::store::Store>::Error>> + std::marker::Unpin>, std::boxed::Box<dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin>, [closure@tests/echo.rs:16:15: 27:10 message:_, store:_, id:_]> : futures_util::try_stream::TryStreamExt`
`futures_util::future::then::Then<std::boxed::Box<dyn core::future::future::Future<Output=std::result::Result<std::option::Option<std::string::String>, <S as rustin::store::Store>::Error>> + std::marker::Unpin>, std::boxed::Box<dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin>, [closure@tests/echo.rs:16:15: 27:10 message:_, store:_, id:_]> : futures_util::future::FutureExt`
`futures_util::future::then::Then<std::boxed::Box<dyn core::future::future::Future<Output=std::result::Result<std::option::Option<std::string::String>, <S as rustin::store::Store>::Error>> + std::marker::Unpin>, std::boxed::Box<dyn futures_core::stream::Stream<Item=std::result::Result<rustin::callback::Action, rustin::error::Error>> + std::marker::Unpin>, [closure@tests/echo.rs:16:15: 27:10 message:_, store:_, id:_]> : futures_util::try_stream::TryStreamExt`
error: aborting due to 2 previous errors
Some errors occurred: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: Could not compile `rustin`.
To learn more, run the command again with --verbose.
use futures::{
future::ok,
prelude::*,
stream::{empty, once},
};
use rustin::{message::IncomingMessage, store::Store, ActionStream};
fn echo<S>(message: &IncomingMessage, store: &mut S) -> ActionStream
where
S: Store,
{
let id = message.user().id();
store
.get(id)
.then(|result| match result {
Ok(Some(id)) => Box::new(once(ok(message.reply(format!(
"Hello again, {}!",
message.user().name().unwrap_or(&id)
))))) as ActionStream,
Ok(None) => {
store.set(id, "1");
Box::new(empty()) as ActionStream
}
_ => panic!("store error"),
})
.into_stream()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.