chromium / subspace

A concept-centered standard library for C++20, enabling safer and more reliable products and a more modern feel for C++ code.; Also home of Subdoc the code-documentation generator.
https://suslib.cc
Apache License 2.0
89 stars 15 forks source link

Consider split() for Box<DynFnOnce> #360

Open danakj opened 1 year ago

danakj commented 1 year ago

We lost split() with FnOnceRef: https://github.com/chromium/subspace/pull/356/commits/72968c4394361c33439978b3b3496aed3cd6c998#diff-ecdf6bec3f3f1f3c1b27e1acbc1104b1573eab15975d292679e8a4d6a2518cd5L424-L463

We could potentially be able to split a Box into two, where one of them will be called and then the other would panic if called. Since DynFnOnce is not cloneable, there's no way to split with ownership involved at the moment.

For a DynFnOnce& reference, the reference itself is copyable so there's nothing needed.

What does Rust do here for Box?