Consider the following example (playground link):
struct Wrapper(String);
async fn foo(my_slice: &[Wrapper]) {
bar(my_slice).await; // Error!
}
async fn bar(string_slice: &[String]) { ... }
I'm having difficulty writing foo such that I can call bar(my_slice) without cloning my_slice, as String doesn't implement Copy.
I'm aware of the unsafe method to do this: Put a #[repr(transparent)] on Wrapper and mem::transmute it, but I'm looking for ways to do this in entirely safe Rust.
I've attempted to implement From, but slices since are always considered a foreign type and thus I've ran into orphan rules (foreign trait implementation on a foreign type) that prohibit me from doing so.
Unfortunately, I only have the ability to modify foo or Wrapper as bar is auto-generated.
Is there any way to safely cast &[Wrapper] to &[String] without a clone?