We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5d84938 commit d7cf3efCopy full SHA for d7cf3ef
1 file changed
libcc2rs/src/rc.rs
@@ -1077,7 +1077,7 @@ pub struct AnyPtr {
1077
ptr: Rc<dyn ErasedPtr>,
1078
}
1079
1080
-impl<T: Clone + ByteRepr + 'static> Ptr<T> {
+impl<T: ByteRepr + 'static> Ptr<T> {
1081
pub fn to_any(&self) -> AnyPtr {
1082
AnyPtr {
1083
ptr: Rc::new(self.clone()),
@@ -1093,6 +1093,11 @@ impl Default for AnyPtr {
1093
1094
impl AnyPtr {
1095
pub fn cast<T: 'static>(&self) -> Option<Ptr<T>> {
1096
+ if let Some(p) = self.ptr.as_any().downcast_ref::<Ptr<()>>() {
1097
+ if p.is_null() {
1098
+ return Some(Ptr::<T>::null());
1099
+ }
1100
1101
self.ptr.as_any().downcast_ref::<Ptr<T>>().cloned()
1102
1103
0 commit comments