如何解决 IP 类型推断问题,得到 "cannot infer type for type `{integer}`"?
How can I resolve a problem with IP type inferences, getting "cannot infer type for type `{integer}`"?
我不断收到这样的警告,
error[E0698]: type inside `async fn` body must be known in this context
--> src/http.rs:38:10
|
38 | .run(([127, 0, 0, 1], 3030))
| ^^^ cannot infer type for type `{integer}`
对于 IP 地址中的每个八位字节。我该如何解决这个问题。
在不知道 run()
的签名的情况下,无法判断类型推断失败的原因,但您可以明确地进行转换并完全避开类型推断,这肯定会与 run(addr)
一起使用。
use std::net;
// `SocketAddr` via `From` with (ip,port) tuple
let addr: net::SocketAddr = net::SocketAddr::from(([127, 0, 0, 1], 3030));
// `SocketAddr` from string
let addr: net::SocketAddr = "127.0.0.1:3030".parse().unwrap();
我不断收到这样的警告,
error[E0698]: type inside `async fn` body must be known in this context
--> src/http.rs:38:10
|
38 | .run(([127, 0, 0, 1], 3030))
| ^^^ cannot infer type for type `{integer}`
对于 IP 地址中的每个八位字节。我该如何解决这个问题。
在不知道 run()
的签名的情况下,无法判断类型推断失败的原因,但您可以明确地进行转换并完全避开类型推断,这肯定会与 run(addr)
一起使用。
use std::net;
// `SocketAddr` via `From` with (ip,port) tuple
let addr: net::SocketAddr = net::SocketAddr::from(([127, 0, 0, 1], 3030));
// `SocketAddr` from string
let addr: net::SocketAddr = "127.0.0.1:3030".parse().unwrap();