Rust trait corresponding to the as cast

There are several traits (From, Into, num::FromPrimitive, etc.) for casting types in Rust. Primitive types can also be casted using the as keyword. I wonder is there a trait corresponding to the as casting? There's num_traits::cast::AsPrimitive but it doesn't work for Enum which can be casted into integers using as.

There's no trait for casting with the as keyword.


Thanks a lot, Alice!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.