| ▲ | singpolyma3 2 hours ago | |
I have to sit with the specific example, but a PrintWriter struct which owns a Box<impl Writer> and has no generics should be quite doable I'd think? | ||
| ▲ | Darmani 2 hours ago | parent [-] | |
*`dyn Writer`. `impl Writer` can only be used in function parameters. This was one of the example approaches I gave. This works...at first. The problem is that, if you want to add a new function to the Writer trait which makes Writer no longer dyn-compatible, such as, say, any async function, then you can no longer write `Box<dyn Writer>` and need to rewrite all code that uses it. (although you can dig under the hood and specify a pinned-down Future type, covering one kind of awfulness with another) | ||