rustrust-async-std

async_std 1.8 has unresolved imports for items in `async_std::channel`


I'm building an application using async_std but this returns an unresolved import error:

use async_std::sync::Sender;

After looking at the documentation for 1.8.0, it seems like async_std::sync has been deprecated in favor of async_std::channel. This was not the case in 1.7.0.

After updating to 1.8.0, I tried to replace use async_std::sync::Sender; with use async_std::channel::Sender.

The documentation seems to agree that it should work, but I still get an unresolved import error.

What am I missing?


Solution

  • You need to enable the unstable feature:

    async-std = { version = "1.8.0" , features = ["unstable"] }
    

    The documentation informs you of this about async_std::sync in both 1.7 and 1.8:

    docs showing unstable requirement

    Unfortunately, in 1.8, async_std::channel always exists, but it only re-exports the contents when unstable is present:

    //! Channels
    
    #[cfg(feature = "unstable")]
    #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
    #[doc(inline)]
    pub use async_channel::*;