summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authordhivael <dhivael.git@eno.space>2017-05-29 23:41:04 +0200
committerdhivael <dhivael.git@eno.space>2017-05-29 23:41:04 +0200
commit8ac5ecc41718c4a5c3334e0f61566281a485447f (patch)
tree910e8f77ca3c36688c10f143036e322f7fed3593
parent4b18f6485ea120d8a006690378e29398646e17fd (diff)
add explicit marker for owned+dropped data
-rw-r--r--src/lib.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 33ace3e..6b261e0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,6 +3,7 @@
extern crate errno;
extern crate libc;
+use std::marker::PhantomData;
use std::mem;
use std::net::*;
use std::os::raw::*;
@@ -33,21 +34,22 @@ pub struct IfAddr {
struct IfaddrHandle {
addrs: *mut libc::ifaddrs,
+ marker: PhantomData<libc::ifaddrs>,
}
-struct IfaddrIter<'a>(*const libc::ifaddrs, std::marker::PhantomData<&'a libc::ifaddrs>);
+struct IfaddrIter<'a>(*const libc::ifaddrs, PhantomData<&'a libc::ifaddrs>);
impl IfaddrHandle {
fn new() -> Result<IfaddrHandle, errno::Errno> {
let mut addrs: *mut libc::ifaddrs = unsafe { mem::uninitialized() };
match unsafe { libc::getifaddrs(&mut addrs as *mut *mut libc::ifaddrs) } {
- 0 => Ok(IfaddrHandle{addrs: addrs}),
+ 0 => Ok(IfaddrHandle{addrs: addrs, marker: PhantomData}),
_ => Err(errno::errno()),
}
}
fn iter(&self) -> IfaddrIter {
- IfaddrIter(self.addrs, std::marker::PhantomData)
+ IfaddrIter(self.addrs, PhantomData)
}
}