Crates.io | must-done |
lib.rs | must-done |
version | 0.1.0 |
source | src |
created_at | 2023-06-07 05:49:41.120091 |
updated_at | 2023-06-07 05:49:41.120091 |
description | An experimental Future that is guaranteed to be done |
homepage | |
repository | https://github.com/ihciah/must-done |
max_upload_size | |
id | 884507 |
size | 4,065 |
An experimental Future that is guaranteed to be done.
In some cases, we need to ensure that the Future is executed and terminated, especially those Futures that have side effects when canceled.
For example, under io_uring, because we cannot ensure that the Future is executed, we have to pass the buffer ownership on the IO interface, which makes the interface very cumbersome to use.
Using this Future wrapper, users can be sure that the Future will be terminated at compile time.
Inspired by dtolnay's no-panic, I define a Future Wrapper and placed a Guard in it.
If the Future can not be proven terminated, then the Guard will be dropped, and the drop method of the Guard needs to link to an external library that does not exist, which will trigger an error during the link period; and if the Future must be terminated, the drop implementation will not be used due to dead code elimination.
panic = "abort"
to avoid future be dropped due to panic possibility.[profile.dev]
opt-level = 3
panic = "abort"