I wanted to have a linked list of Arc<dyn DynTask> for a toy async runtime I am working on. It took a bit of effort but I did eventually manage to define an adaptor that works. I thought I would share it here for lack of any other suitable discussion place.
The basis of this impl is the FatLink, which is a linked list link + a type-erased get_value function that the Adapter impl uses.
Unfortunately, I needed to add this get_link method to the DynTask trait, which requires feature(arbitrary_self_types). I could not figure out a way to avoid the nightly dep here.
I wanted to have a linked list of
Arc<dyn DynTask>
for a toy async runtime I am working on. It took a bit of effort but I did eventually manage to define an adaptor that works. I thought I would share it here for lack of any other suitable discussion place.The basis of this impl is the
FatLink
, which is a linked list link + a type-erasedget_value
function that theAdapter
impl uses.Unfortunately, I needed to add this
get_link
method to theDynTask
trait, which requiresfeature(arbitrary_self_types)
. I could not figure out a way to avoid the nightly dep here.https://github.com/conradludgate/arc-discharge/blob/dbd9b0aeb0d1389262a203eeff3bc2e9b0c91a37/src/linked_list.rs