Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::convert::{TryFrom, TryInto};
- use num_traits::cast::AsPrimitive;
- struct Numeric(u64);
- enum SomeType {
- Numeric(Numeric),
- }
- impl<T: Into<u64>> From<T> for SomeType {
- fn from(n: T) -> Self {
- SomeType::Numeric(Numeric(n.into()))
- }
- }
- fn main() {
- let x: SomeType = 0u8.try_into().unwrap();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement