20 lines
300 B
Rust
20 lines
300 B
Rust
use std::convert::Into;
|
|
|
|
#[allow(dead_code)]
|
|
#[derive(Debug)]
|
|
struct Number {
|
|
value: i32,
|
|
}
|
|
|
|
impl Into<Number> for i32 {
|
|
fn into(self) -> Number {
|
|
Number { value: self }
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let int = 5;
|
|
let num: Number = int.into();
|
|
println!("My number is {:?}", num);
|
|
}
|