Simple Example source code from https://docs.rs/tiberius/0.3.1/tiberius/
//-----------------------------------------------------------------------------------------------
[
extern crate tiberius;
use futures::Future;
use futures_state_stream::StateStream;
use tokio::executor::current_thread;
use tiberius::SqlConnection;
fn main() {
// 1: for windows we demonstrate the hardcoded variant
// which is equivalent to:
// let conn_str = "server=tcp:localhost,1433;integratedSecurity=true;";
// let future = SqlConnection::connect(conn_str).and_then(|conn| {
// and for linux we use the connection string from an environment variable
let conn_str = if cfg!(windows) {
"server=tcp:localhost,1433;integratedSecurity=true;".to_owned()
} else {
::std::env::var("TIBERIUS_TEST_CONNECTION_STRING").unwrap()
};
let future = SqlConnection::connect(conn_str.as_str())
.and_then(|conn| {
conn.simple_query("SELECT 1+2").for_each(|row| {
let val: i32 = row.get(0);
assert_eq!(val, 3i32);
Ok(())
})
})
.and_then(|conn| conn.simple_exec("create table #Temp(gg int);"))
.and_then(|(_, conn)| conn.simple_exec("UPDATE #Temp SET gg=1 WHERE gg=1"));
current_thread::block_on_all(future).unwrap();
it can not be compiled, it reported "error[E0599]: no method named for_each found for type "
C:/Users/Administrator/.cargo/bin/cargo.exe run --package mssql --bin mssql
Compiling mssql v0.1.0 (D:\rust\mssql)
warning: use of deprecated item 'tokio::executor::current_thread': use tokio-current-thread crate or functions in tokio::runtime::current_thread instead
--> src\main.rs:7:5
7
use tokio::executor::current_thread;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: #[warn(deprecated)] on by default
error[E0599]: no method named for_each found for type tiberius::stmt::QueryResult<tiberius::query::ResultSetStream<std::boxed::Box<dyn tiberius::BoxableIo>, tiberius::query::QueryStream<std::boxed::Box<dyn tiberius::BoxableIo>>>> in the current scope
--> src\main.rs:25:45
25
conn.simple_query("SELECT 1+2").for_each(
row
{
^^^^^^^^
= note: the method for_each exists but the following trait bounds were not satisfied:
&mut tiberius::stmt::QueryResult<tiberius::query::ResultSetStream<std::boxed::Box<dyn tiberius::BoxableIo>, tiberius::query::QueryStream<std::boxed::Box<dyn tiberius::BoxableIo>>>> : futures_state_stream::StateStream&mut tiberius::stmt::QueryResult<tiberius::query::ResultSetStream<std::boxed::Box<dyn tiberius::BoxableIo>, tiberius::query::QueryStream<std::boxed::Box<dyn tiberius::BoxableIo>>>> : std::iter::Iterator
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a use for it:
5
use futures_state_stream::StateStream;
error: aborting due to previous error
For more information about this error, try rustc --explain E0599.
error: Could not compile mssql.
To learn more, run the command again with --verbose.
Simple Example source code from https://docs.rs/tiberius/0.3.1/tiberius/ //----------------------------------------------------------------------------------------------- [ extern crate tiberius; use futures::Future; use futures_state_stream::StateStream; use tokio::executor::current_thread; use tiberius::SqlConnection;
fn main() {
} ] //-----------------------------------------------------------------------------------------------
it can not be compiled, it reported "error[E0599]: no method named
for_each
found for type "= note: #[warn(deprecated)] on by default
for_each
found for typetiberius::stmt::QueryResult<tiberius::query::ResultSetStream<std::boxed::Box<dyn tiberius::BoxableIo>, tiberius::query::QueryStream<std::boxed::Box<dyn tiberius::BoxableIo>>>>
in the current scope --> src\main.rs:25:45for_each
exists but the following trait bounds were not satisfied:&mut tiberius::stmt::QueryResult<tiberius::query::ResultSetStream<std::boxed::Box<dyn tiberius::BoxableIo>, tiberius::query::QueryStream<std::boxed::Box<dyn tiberius::BoxableIo>>>> : futures_state_stream::StateStream
&mut tiberius::stmt::QueryResult<tiberius::query::ResultSetStream<std::boxed::Box<dyn tiberius::BoxableIo>, tiberius::query::QueryStream<std::boxed::Box<dyn tiberius::BoxableIo>>>> : std::iter::Iterator
= help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add ause
for it:error: aborting due to previous error
For more information about this error, try
rustc --explain E0599
. error: Could not compilemssql
.To learn more, run the command again with --verbose.
Process finished with exit code 101