-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
What does this lint do?
It errors on const tokio runtimes.
Categories (optional)
- Kind: Correctness
- Deny by default
What is the advantage of the recommended code over the original code
It avoids errors like the following:
Io(Custom { kind: Other, error: "reactor gone" })
const creates a new copy of the runtime every time it's used, while static uses the same runtime each time.
I was using this as RUNTIME.block_on(), which takes &mut, so possibly this could be expanded to any &mut use of a const.
Drawbacks
None.
Example
pub const RUNTIME: Lazy<Runtime> = Lazy::new(|| Runtime::new().unwrap());should instead be
pub static RUNTIME: Lazy<Runtime> = Lazy::new(|| Runtime::new().unwrap());Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints