Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You might be interested in Rust's either crate (not built-in): https://docs.rs/either/latest/either/


Yes, thank you that should work since both libs L1, L2 and main can all refer to Either<A, B>.

This parallels a similar solution to the nominal sum types I ended up making for Java (Either<A, B>, Option3<A, B, C>, etc) with these generic types in a common shared library and other libraries and consumers of both accessing the shared type.

One more question: In Rust is Either<A, B> type-erased, specializations generated, or something else?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: