mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-25 10:23:23 +00:00
Simplify current codes with TryFromNum
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
6ecc7dc557
commit
6cea03b871
@ -71,7 +71,9 @@ fn fn_body_tokens(value_name: &str, data_enum: &DataEnum, ident: Ident) -> Token
|
||||
let statement = quote!(#value => ::core::result::Result::Ok(#ident::#vairant_ident),);
|
||||
match_bodys.append_all(statement);
|
||||
}
|
||||
match_bodys.append_all(quote!(_ => core::result::Result::Err(::int_to_c_enum::TryFromIntError::InvalidValue),));
|
||||
match_bodys.append_all(
|
||||
quote!(_ => core::result::Result::Err(::int_to_c_enum::TryFromIntError::InvalidValue),),
|
||||
);
|
||||
let param = format_ident!("{}", value_name);
|
||||
quote!(match #param {
|
||||
#match_bodys
|
||||
|
@ -33,7 +33,7 @@
|
||||
//! }
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//!
|
||||
|
||||
#![no_std]
|
||||
|
||||
@ -44,4 +44,4 @@ pub enum TryFromIntError {
|
||||
}
|
||||
|
||||
#[cfg(feature = "derive")]
|
||||
pub use int_to_c_enum_derive::TryFromInt;
|
||||
pub use int_to_c_enum_derive::TryFromInt;
|
||||
|
Reference in New Issue
Block a user