@@ -457,6 +457,20 @@ pub const fn can_be_subtype(ty: WrappedValue, subtype: WrappedValue) -> bool {
457457 }
458458}
459459
460+ /// Extracts an [`Argument`] from the provided [`Arguments`] by its [`Name`].
461+ #[ must_use]
462+ pub const fn extract_argument ( args : Arguments , name : Name ) -> Option < Argument > {
463+ let mut i = 0 ;
464+ while i < args. len ( ) {
465+ let arg = args[ i] ;
466+ if str_eq ( arg. 0 , name) {
467+ return Some ( arg) ;
468+ }
469+ i += 1 ;
470+ }
471+ None
472+ }
473+
460474/// Checks whether the given `val` exists in the given `arr`.
461475#[ must_use]
462476pub const fn str_exists_in_arr ( val : & str , arr : & [ & str ] ) -> bool {
@@ -863,6 +877,36 @@ macro_rules! assert_field_args {
863877 } ;
864878}
865879
880+ #[ macro_export]
881+ macro_rules! assert_field_arg_nullable {
882+ (
883+ $ty: ty,
884+ $scalar: ty,
885+ $field_name: expr,
886+ $arg_name: expr
887+ $( , $err_prefix: expr) ? $( , ) ?
888+ ) => {
889+ const {
890+ const TY_NAME : & :: core:: primitive:: str =
891+ <$ty as $crate:: macros:: reflect:: BaseType <$scalar>>:: NAME ;
892+ const FIELD_NAME : & :: core:: primitive:: str = $field_name;
893+ const ARGS : $crate:: macros:: reflect:: Arguments =
894+ <$ty as $crate:: macros:: reflect:: FieldMeta <
895+ $scalar,
896+ { $crate:: checked_hash!( FIELD_NAME , $ty, $scalar, $err_prefix) } ,
897+ >>:: ARGUMENTS ;
898+ const ARG_NAME : & :: core:: primitive:: str = $arg_name;
899+ const ARG : $crate:: macros:: reflect:: Argument =
900+ $crate:: macros:: reflect:: extract_argument( ARGS , ARG_NAME ) . unwrap(
901+ $crate:: const_concat!(
902+ $err_prefix, "Field `" , FIELD_NAME , "` has no argument `" , ARG_NAME , "`" ,
903+ ) ,
904+ ) ;
905+ todo!( )
906+ }
907+ } ;
908+ }
909+
866910/// Concatenates `const` [`str`](prim@str)s in a `const` context.
867911#[ macro_export]
868912macro_rules! const_concat {
0 commit comments