Created
July 6, 2019 08:19
-
-
Save BadUncleX/531a63351e11b34c5965faf806b9a039 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::convert::From; | |
#[derive(Debug)] | |
struct Number { | |
value: i32, | |
} | |
impl From<i32> for Number { | |
fn from(item: i32) -> Self { | |
Number { value: item } | |
} | |
} | |
fn main() { | |
let num = Number::from(30); | |
println!("My number is {:?}", num); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment