Refactor project structure

This commit is contained in:
Zhang Junyang
2024-02-27 16:40:16 +08:00
committed by Tate, Hongliang Tian
parent bd878dd1c9
commit e3c227ae06
474 changed files with 77 additions and 77 deletions

View File

@ -0,0 +1,24 @@
// SPDX-License-Identifier: MPL-2.0
use int_to_c_enum::TryFromInt;
#[derive(TryFromInt, Debug, PartialEq, Eq)]
#[repr(u8)]
enum Color {
Red = 1,
Blue = 2,
Green = 3,
}
#[test]
fn conversion() {
let color = Color::try_from(1).unwrap();
println!("color = {color:?}");
assert!(color == Color::Red);
}
#[test]
fn invalid_value() {
let color = Color::try_from(4);
assert!(color.is_err());
}