rust_icu_common

Macro generalized_fallible_setter

Source
macro_rules! generalized_fallible_setter {
    ($top_level_method_name:ident, $impl_name:ident, [ $( $arg:ident : $arg_type:ty, )* ]) => { ... };
}
Expand description

Expands into a setter methods that forwards all its arguments between []’s and returns a Result<(), common::Error>.

The invocation:

impl _ {
    generalized_fallible_setter!(
        get_context,
        unum_getContext,
        [context_type: sys::UDisplayContextType, ]
    );
}

allows us to bind the function:

UDisplayContext unum_setContext(
    const SOMETYPE* t,
    UDisplayContext value,
    UErrorCode* status
);

which then becomes:

impl _ {
  fn set_context(&self, value: sys::UDisplayContext) -> Result<(), common::Error>;
}

where Self has an internal representation named exactly Self::rep.