3 ms·
That's really cool! Surprisingly, I _did_ actually end up doing something like `BlackHole` at one point in a project. I was trying to implement a connection typ
by saghm 5y ago
That's really cool! Surprisingly, I _did_ actually end up doing something like `BlackHole` at one point in a project. I was trying to implement a connection type so that it got automatically returned to a connection pool when dropped, but the combination of the trickiness of trying to do async things inside of a `Drop` implementation and some external requirements that were assuming a language without RAII or ownership semantics, I couldn't just pass the connection's ownership back to the pool. I ended up making a replica of the internals of the connection with I/O implementations that basically did the same thing as `BlackHole` and then swapping that out for the real connection internals and then passing a newly-constructed connection back to the pool and then letting the original connection (now with black hole internals) get dropped instead. In this case, the black hole implementations were never actually invoked for anything and were just there to satisfy the type system, but it turns out that there are bizarre cases where that might actually be useful!