小编jul*_*lia的帖子

如何解决错误“线程 'main' 在 'no current reactor' 中恐慌”?

我正在尝试连接到数据库:

extern crate tokio; // 0.2.6, features = ["full"]
extern crate tokio_postgres; // 0.5.1

use futures::executor;
use tokio_postgres::NoTls;

fn main() {
    let fut = async {
        let (client, connection) = match tokio_postgres::connect("actual stuff", NoTls).await {
            Ok((client, connection)) => (client, connection),
            Err(e) => panic!(e),
        };
        tokio::spawn(async move {
            if let Err(e) = connection.await {
                eprintln!("connection error: {}", e);
            }
        });

        let rows = match client
            .query(
                "SELECT $1 FROM planet_osm_point WHERE $1 IS NOT NULL LIMIT 100",
                &[&"name"],
            )
            .await
        { …
Run Code Online (Sandbox Code Playgroud)

future rust rust-tokio

5
推荐指数
1
解决办法
5111
查看次数

标签 统计

future ×1

rust ×1

rust-tokio ×1