Add OsString and PathBuf
OsString and PathBuf are commonly used types and should be supported.
What should happen if you encode an OsString or PathBuf on Unix and decode it on Windows, or vise versa? These types have no canonical, portable encoding and, while serde would return an error while encoding non-UTF8 paths, bitcode doesn't support errors while encoding. For OsString, serde currently serializes the equivalent of an enum with a Unix variant and an Windows variant.
I also looked at what bincode does and it is similar to serde, with an encoding error.
Doing it like that is definitely not ideal 😅 and not compatible with bitcode v0.6.
Though I had an idea while showering:
How about adding a feature flag non-portable?
Encode and Decode implementations gated behind non-portable are platform dependent.
This does require documenting features. This solution also does not require an encode error.
The error then happens on decode.
The alternative is to use #[bitcode(with_serde)] if it becomes available.