Skip to content

Commit

Permalink
Insn Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
c3rb3ru5d3d53c committed Oct 22, 2024
1 parent 62c7ec5 commit f028e8c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions capstone-rs/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ pub struct Insn<'a> {
pub(crate) _marker: PhantomData<&'a InsnDetail<'a>>,
}

impl<'a> Clone for Insn<'a> {
fn clone(&self) -> Self {
Self {
insn: self.insn.clone(),
_marker: PhantomData,
}
}
}

/// Contains architecture-independent details about an [`Insn`].
///
/// To get more detail about the instruction, enable extra details for the
Expand Down
15 changes: 15 additions & 0 deletions capstone-sys/pre_generated/capstone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15715,6 +15715,21 @@ pub struct cs_insn {
#[doc = " Pointer to cs_detail.\n NOTE: detail pointer is only valid when both requirements below are met:\n (1) CS_OP_DETAIL = CS_OPT_ON\n (2) Engine is not in Skipdata mode (CS_OP_SKIPDATA option set to CS_OPT_ON)\n\n NOTE 2: when in Skipdata mode, or when detail mode is OFF, even if this pointer\n is not NULL, its content is still irrelevant."]
pub detail: *mut cs_detail,
}

impl Clone for cs_insn {
fn clone(&self) -> Self {
Self {
id: self.id,
address: self.address,
size: self.size,
bytes: self.bytes,
mnemonic: self.mnemonic,
op_str: self.op_str,
detail: self.detail.clone(),
}
}
}

impl ::core::fmt::Debug for cs_insn {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
write!(
Expand Down

0 comments on commit f028e8c

Please sign in to comment.