Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello, I have encountered a question: functions in traits cannot be declared async #481

Open
TTTq opened this issue Jan 11, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@TTTq
Copy link

TTTq commented Jan 11, 2024

error[E0706]: functions in traits cannot be declared async
--> xxx\Rust.cargo\registry\src\mirrors.ustc.edu.cn-61ef6e0cd06fb9b8\fast_pool-0.2.0\src\lib.rs:53:5
|
53 | async fn connect(&self) -> Result<Self::Connection, Self::Error>;
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| async because of this
|
= note: async trait functions are not currently supported
= note: consider using the async-trait crate: https://crates.io/crates/async-trait
= note: see issue #91611 rust-lang/rust#91611 for more information

I see that it is

///create Connection and check Connection
async fn connect(&self) -> Result<Self::Connection, Self::Error>;
///check Connection is alive? if not return Error(Connection will be drop)
async fn check(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>;

The reason for using asynchronous here

@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


image

image

@zhuxiujia
Copy link
Member

error[E0706]: functions in traits cannot be declared async --> xxx\Rust.cargo\registry\src\mirrors.ustc.edu.cn-61ef6e0cd06fb9b8\fast_pool-0.2.0\src\lib.rs:53:5 | 53 | async fn connect(&self) -> Result<Self::Connection, Self::Error>; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | async because of this | = note: async trait functions are not currently supported = note: consider using the async-trait crate: https://crates.io/crates/async-trait = note: see issue #91611 rust-lang/rust#91611 for more information

I see that it is

///create Connection and check Connection
async fn connect(&self) -> Result<Self::Connection, Self::Error>;
///check Connection is alive? if not return Error(Connection will be drop)
async fn check(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>;

The reason for using asynchronous here

rustup update update your rust compiler.

@zhuxiujia zhuxiujia added the help wanted Extra attention is needed label Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants