Skip to content

Commit

Permalink
Remove clear_and_parse inherent method in favor of a trait fn.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 658098868
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jul 31, 2024
1 parent 9d628f8 commit 6fdcc0b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/google/protobuf/compiler/rust/message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ void GenerateRs(Context& ctx, const Descriptor& msg) {
impl $pb$::ClearAndParse for $Msg$ {
fn clear_and_parse(&mut self, data: &[u8]) -> Result<(), $pb$::ParseError> {
self.clear_and_parse(data)
$Msg::clear_and_parse$
}
}
Expand Down Expand Up @@ -1235,12 +1235,9 @@ void GenerateRs(Context& ctx, const Descriptor& msg) {
$raw_arena_getter_for_message$
pub fn clear_and_parse(&mut self, data: &[u8]) -> Result<(), $pb$::ParseError> {
$Msg::clear_and_parse$
}
pub fn parse(data: &[u8]) -> Result<Self, $pb$::ParseError> {
let mut msg = Self::new();
msg.clear_and_parse(data).map(|_| msg)
$pb$::ClearAndParse::clear_and_parse(&mut msg, data).map(|_| msg)
}
pub fn as_view(&self) -> $Msg$View {
Expand Down

0 comments on commit 6fdcc0b

Please sign in to comment.