anchor.diff:  get_field_occurrence(#?gpb_field{occurrence=Occurrence}) -> Occurrence;
   get_field_occurrence(#gpb_oneof{})                       -> optional.
   
  +get_field_rnum(#?gpb_field{rnum=RNum}) -> RNum;
  +get_field_rnum(#gpb_oneof{rnum=RNum})  -> RNum.
  +
   %% -> {Optionals, NonOptionals}
   key_partition_on_optionality(Key, Items) ->
       lists:partition(fun(Item) ->
  
positive.code:      || {{msg, MsgName}, Fields} <- Defs].
  
  format_nif_cc_packer(CPkg, MsgName, Fields, Defs, Opts) ->
      PackFnName = mk_c_fn(p_msg_, MsgName),
      CMsgType = CPkg ++ "::" ++ dot_replace_s(MsgName, "::"),
      ["static int\n",
       PackFnName,"(ErlNifEnv *env, const ERL_NIF_TERM r, ",CMsgType," *m)\n",
       "{\n",
       "    int arity;\n"
       "    const ERL_NIF_TERM *elem;\n"
       "\n"
       "    if (!enif_get_tuple(env, r, &arity, &elem))\n"
       "        return 0;\n"
       "\n",
       ?f("    if (arity != ~w)\n"
          "        return 0;\n",
          [length(Fields) + 1]),
       "\n",
       [begin
            SrcVar = ?f("elem[~w]",[I]),
            format_nif_cc_field_packer(SrcVar, "m", Field, Defs, Opts)
  
negative.code:                      true  -> MiscAtoms0 ++ [true, false];
                       false -> MiscAtoms0
                   end,
      FieldAtoms = if Maps ->
                           lists:usort(
                             lists:flatten(
                               [[get_field_name(Field) || Field <- Fields]
                                || {{msg,_MsgName}, Fields} <- Defs]));
                      not Maps ->
                           []
                   end,
      MiscAtoms2 = MiscAtoms1 ++ FieldAtoms,
      Atoms = lists:usort(EnumAtoms ++ RecordAtoms ++ OneofNames ++ MiscAtoms2),
      AtomVars = [{mk_c_var(gpb_aa_, A), A} || A <- Atoms],
  
      [[?f("static ERL_NIF_TERM ~s;\n", [Var]) || {Var,_Atom} <- AtomVars],
  