add examle
This commit is contained in:
parent
fc257be1a4
commit
72fe5a657c
1 changed files with 6 additions and 2 deletions
|
@ -48,7 +48,7 @@ impl TryFrom<u32> for MyType2Val {
|
|||
match value {
|
||||
0x1 => Ok(MyType2Val::A),
|
||||
0x2 => Ok(MyType2Val::B),
|
||||
_ => panic!()
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,11 @@ impl MyTrait for MyType2 {
|
|||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
|
||||
|
||||
let x = MyType1 {};
|
||||
println!("{}", x.converted());
|
||||
|
||||
let y = MyType2Val::A;
|
||||
let _y = <MyType2Val as TryInto<u32>>::try_into(y).unwrap();
|
||||
let _y = <MyType2Val as Into<u32>>::into(y);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue