Skip to content

Commit 08aedca

Browse files
committed
impl Clone for Box<Message>
1 parent 269c96a commit 08aedca

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

protobuf/src/core.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,21 @@ pub fn message_down_cast<'a, M: Message + 'a>(m: &'a Message) -> &'a M {
213213
m.as_any().downcast_ref::<M>().unwrap()
214214
}
215215

216+
impl Clone for Box<dyn Message> {
217+
fn clone(&self) -> Self {
218+
use std::ops::Deref;
219+
self.descriptor().clone(self.deref())
220+
}
221+
}
222+
223+
#[cfg(off)] // don't need it
224+
impl PartialEq for Box<Message> {
225+
fn eq(&self, other: &Box<Message>) -> bool {
226+
use std::ops::Deref;
227+
self.descriptor() == other.descriptor() && self.descriptor().eq(self.deref(), other.deref())
228+
}
229+
}
230+
216231
/// Parse message from stream.
217232
pub fn parse_from<M: Message>(is: &mut CodedInputStream) -> ProtobufResult<M> {
218233
let mut r: M = Message::new();

0 commit comments

Comments
 (0)