Skip to content

Instantly share code, notes, and snippets.

@BadUncleX
Created July 6, 2019 08:19
Show Gist options
  • Save BadUncleX/531a63351e11b34c5965faf806b9a039 to your computer and use it in GitHub Desktop.
Save BadUncleX/531a63351e11b34c5965faf806b9a039 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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