19 lines
284 B
Rust
19 lines
284 B
Rust
|
use std::convert::From;
|
||
|
|
||
|
#[allow(dead_code)]
|
||
|
#[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);
|
||
|
}
|