Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- struct MyNumber(i8);
- impl From<i8> for MyNumber {
- fn from(i: i8) -> MyNumber {
- MyNumber(i)
- }
- }
- fn main() {
- let n = MyNumber::from(42);
- println!("From: {:?}", n);
- let nn: MyNumber = 5.into();
- println!("Into: {:?}", nn);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement