@bitshiftmask The lifetime 'de of T can't be given as a generic parameter to rx_with, as it is the lifetime of those msg bytes, which is shorter than that function itself. Instead, I suppose rx_with should dictate the lifetime, not the caller. (But moving it to a for<'de> gives another error.)
@bitshiftmask rx_with, not main, should pick the lifetime 'de, but main picks the type T (BorrowedData<'a>) which already contains that lifetime. That's a problem. Rust does not have template template parameters like C++, to give it BorrowedData without param and let rx_with pick it.
@bitshiftmask Making it specific for BorrowedData works:
Here, rx_with can pick the lifetime 'de, because it picks the whole type BorrowedData<'de>:
Here, rx_with can pick the lifetime 'de, because it picks the whole type BorrowedData<'de>:
@bitshiftmask Passing a whole generic type as generic argument, with a 'hole' left for the lifetime that rx_with can fill in, would require higher kinded types. Or some ugly hacks with traits that aren't nice to use. :(
Loading suggestions...