Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing Clone for the Insn and cs_insn Structures #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading