|
|
|
@ -23,7 +23,10 @@ namespace rust { |
|
|
|
|
void RepeatedField::InMsgImpl(Context& ctx, const FieldDescriptor& field, |
|
|
|
|
AccessorCase accessor_case) const { |
|
|
|
|
std::string field_name = FieldNameWithCollisionAvoidance(field); |
|
|
|
|
ctx.Emit({{"field", RsSafeName(field_name)}, |
|
|
|
|
ctx.Emit( |
|
|
|
|
{ |
|
|
|
|
{"field", RsSafeName(field_name)}, |
|
|
|
|
{"raw_field_name", field_name}, // Never r# prefixed
|
|
|
|
|
{"RsType", RsTypePath(ctx, field)}, |
|
|
|
|
{"view_lifetime", ViewLifetime(accessor_case)}, |
|
|
|
|
{"view_self", ViewReceiver(accessor_case)}, |
|
|
|
@ -100,10 +103,24 @@ void RepeatedField::InMsgImpl(Context& ctx, const FieldDescriptor& field, |
|
|
|
|
} |
|
|
|
|
)rs"); |
|
|
|
|
} |
|
|
|
|
}}}, |
|
|
|
|
}}, |
|
|
|
|
{"setter", |
|
|
|
|
[&] { |
|
|
|
|
if (accessor_case == AccessorCase::VIEW) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
ctx.Emit({}, R"rs( |
|
|
|
|
pub fn set_$raw_field_name$(&mut self, src: $pb$::RepeatedView<'_, $RsType$>) { |
|
|
|
|
// TODO: Implement IntoProxied and avoid copying.
|
|
|
|
|
self.$field$_mut().copy_from(src); |
|
|
|
|
} |
|
|
|
|
)rs"); |
|
|
|
|
}}, |
|
|
|
|
}, |
|
|
|
|
R"rs( |
|
|
|
|
$getter$ |
|
|
|
|
$getter_mut$ |
|
|
|
|
$setter$ |
|
|
|
|
)rs"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -180,6 +197,8 @@ void RepeatedField::InThunkCc(Context& ctx, |
|
|
|
|
{"clearer_thunk", ThunkName(ctx, field, "clear")}, |
|
|
|
|
{"getter_thunk", ThunkName(ctx, field, "get")}, |
|
|
|
|
{"getter_mut_thunk", ThunkName(ctx, field, "get_mut")}, |
|
|
|
|
{"repeated_copy_from_thunk", |
|
|
|
|
ThunkName(ctx, field, "repeated_copy_from")}, |
|
|
|
|
{"impls", |
|
|
|
|
[&] { |
|
|
|
|
ctx.Emit( |
|
|
|
|