这两个特征(std :: ops :: Add,core :: ops :: Add)提供相同的功能,并且它们都使用相同的示例(两者都使用std::ops::Add).他们的实施者有所不同.
应该默认使用std::ops::Add吗?为什么两者相对而存在呢?
我很好奇这两个模块在实践中有区别吗?如果没有,为什么这两个重复呢?
我正在尝试创建最简单的示例,async fn hello()最终可以打印出Hello World!. 这应该在没有任何外部依赖的情况下发生tokio,就像普通的 Rust 和std. 如果我们可以在不使用unsafe.
#![feature(async_await)]
async fn hello() {
println!("Hello, World!");
}
fn main() {
let task = hello();
// Something beautiful happens here, and `Hello, World!` is printed on screen.
}
Run Code Online (Sandbox Code Playgroud)
async/await这仍然是一个夜间功能,在可预见的未来可能会发生变化。Future实现,我知道tokio.我模糊的理解是,首先,我需要完成Pin任务。所以我继续前进
let pinned_task = Pin::new(&mut task);
Run Code Online (Sandbox Code Playgroud)
但
the trait `std::marker::Unpin` is not implemented for `std::future::GenFuture<[static generator@src/main.rs:7:18: 9:2 {}]>`
Run Code Online (Sandbox Code Playgroud)
所以我想,当然,我可能需要Box它,所以我确定它不会在内存中移动。有点令人惊讶的是,我得到了同样的错误。
到目前为止我能得到的是 …