Support raw pointers in cxx::bridge.
This allows raw pointers to types to be passed into and out of
cxx::bridge extern "C++" APIs. As normal with raw pointers in Rust,
there are no safety or lifetime guarantees.
Passing a raw pointer into such an API requires that the
function be marked "unsafe".
diff --git a/syntax/impls.rs b/syntax/impls.rs
index 3a0b3e0..954f39b 100644
--- a/syntax/impls.rs
+++ b/syntax/impls.rs
@@ -5,6 +5,8 @@
use std::mem;
use std::ops::{Deref, DerefMut};
+use super::Ptr;
+
impl PartialEq for Include {
fn eq(&self, other: &Include) -> bool {
let Include {
@@ -47,6 +49,7 @@
Type::SharedPtr(t) => t.hash(state),
Type::WeakPtr(t) => t.hash(state),
Type::Ref(t) => t.hash(state),
+ Type::Ptr(t) => t.hash(state),
Type::Str(t) => t.hash(state),
Type::RustVec(t) => t.hash(state),
Type::CxxVector(t) => t.hash(state),
@@ -189,6 +192,42 @@
}
}
+impl Eq for Ptr {}
+
+impl PartialEq for Ptr {
+ fn eq(&self, other: &Ptr) -> bool {
+ let Ptr {
+ star: _,
+ mutable,
+ inner,
+ mutability: _,
+ constness: _,
+ } = self;
+ let Ptr {
+ star: _,
+ mutable: mutable2,
+ inner: inner2,
+ mutability: _,
+ constness: _,
+ } = other;
+ mutable == mutable2 && inner == inner2
+ }
+}
+
+impl Hash for Ptr {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ let Ptr {
+ star: _,
+ mutable,
+ inner,
+ mutability: _,
+ constness: _,
+ } = self;
+ mutable.hash(state);
+ inner.hash(state);
+ }
+}
+
impl Eq for SliceRef {}
impl PartialEq for SliceRef {