add examle

This commit is contained in:
qwjyh 2025-01-29 01:50:34 +09:00
parent fc257be1a4
commit 72fe5a657c

View file

@ -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);
}