Implement Deref for PtraceFlags
This commit is contained in:
13
src/flag.rs
13
src/flag.rs
@@ -1,4 +1,5 @@
|
||||
use bitflags::bitflags as inner_bitflags;
|
||||
use core::{mem, ops::Deref, slice};
|
||||
|
||||
macro_rules! bitflags {
|
||||
(
|
||||
@@ -132,6 +133,18 @@ bitflags! {
|
||||
const PTRACE_FLAG_MASK = 0x0000_0000_0000_F000;
|
||||
}
|
||||
}
|
||||
impl Deref for PtraceFlags {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &Self::Target {
|
||||
// Same as to_ne_bytes but in-place
|
||||
unsafe {
|
||||
slice::from_raw_parts(
|
||||
&self.bits as *const _ as *const u8,
|
||||
mem::size_of::<u64>()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const SEEK_SET: usize = 0;
|
||||
pub const SEEK_CUR: usize = 1;
|
||||
|
||||
Reference in New Issue
Block a user