类型冲突,crossterm::Result 和 core::Result 错误 [E0107]:

Clashing types, crossterm::Result and core::Result error[E0107]:

我知道问题是我有两个来自不同库的 Result 类型,但找不到如何修复它。

[dependencies]
crossterm = "0.23"
time = "0.3.9"
tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.11", features = ["blocking", "json"] }
use time::Instant;
use std::collections::HashMap;
use crossterm::{
    event::{self, Event, KeyCode, KeyEvent},
    Result,
};

pub fn read_char() -> Result<char> {
    loop {
        if let Event::Key(KeyEvent {
            code: KeyCode::Char(c),
            ..
        }) = event::read()?
        {
            return Ok(c);
        }
    }
}

fn main() -> Result<(), Box<dyn std::error::Error>> {

    let instant = Instant::now();

    let response = reqwest::blocking::get("https://httpbin.org/ip")?
        .json::<HashMap<String, String>>()?;

    let duration = instant.elapsed();    
    println!("ns = {:?}, response: {:#?}, ", duration.whole_nanoseconds(), response); 
 
    // Any key to continue
    println!("Press any key to continue:");
    println!("{:?}", read_char());

    Ok(())
}

报错:

error[E0107]: this type alias takes 1 generic argument but 2 generic arguments were supplied       
  --> src\main.rs:20:14
   |
20 | fn main() -> Result<(), Box<dyn std::error::Error>> {
   |              ^^^^^^     -------------------------- help: remove this generic argument
   |              |
   |              expected 1 generic argument

我该如何解决这个问题?我搜索过但可能在寻找不正确的术语,例如命名空间别名和 core::Result 错误 [E0107] 并没有真正帮助。

我已经尝试过但没有成功:

fn main() -> core::Result<(), Box<dyn std::error::Error>> {

你在范围内有 crossterm ::Result,所以你必须消除你想要 return 的结果的歧义,否则它只会认为你想要 return crossterm类型:

fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {

    ...

    Ok(())
}