We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd8021d commit 02c2c43Copy full SHA for 02c2c43
1 file changed
libcc2rs/src/rc.rs
@@ -1055,7 +1055,7 @@ pub struct AnyPtr {
1055
pub(crate) ptr: Rc<dyn ErasedPtr>,
1056
}
1057
1058
-impl<T: Clone + ByteRepr + 'static> Ptr<T> {
+impl<T: ByteRepr + 'static> Ptr<T> {
1059
pub fn to_any(&self) -> AnyPtr {
1060
AnyPtr {
1061
ptr: Rc::new(self.clone()),
@@ -1071,6 +1071,11 @@ impl Default for AnyPtr {
1071
1072
impl AnyPtr {
1073
pub fn cast<T: 'static>(&self) -> Option<Ptr<T>> {
1074
+ if let Some(p) = self.ptr.as_any().downcast_ref::<Ptr<()>>() {
1075
+ if p.is_null() {
1076
+ return Some(Ptr::<T>::null());
1077
+ }
1078
1079
self.ptr.as_any().downcast_ref::<Ptr<T>>().cloned()
1080
1081
0 commit comments