I'm trying to write a function that takes a value that can be one of one of several types. I gave Any a try and it worked great... until I needed to accept a type that could be converted to a binary vector, Vec<u8>.
The function looks like:
fn my_func<T>(code: MyEnum, val: T) -> Result<()>
where T: Any + 'static + Send
{
let rval: &(dyn Any + 'static + Send) = &val;
...
}
The most convenient way to call it might be: my_func(code, b"12345");
but the type for the byte string literal is &[u8 ; 5]
and so I'm trying to figure out how to match to that:
Yeah, I was afraid of that. It seems a simple enough solution, but it's for the public API of a library, and I'm sure there would be issues files for it being "broken"!