Skip to content

Commit ce490d9

Browse files
authored
Merge pull request #1440 from cramertj/patch-1
Make CppMutRef's T invariant
2 parents 0503f71 + ef80c45 commit ce490d9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/reference_wrapper.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<'a, T: ?Sized> CppRef<'a, T> {
162162
pub fn const_cast(&self) -> CppMutRef<'a, T> {
163163
CppMutRef {
164164
ptr: self.ptr as *mut T,
165-
phantom: self.phantom,
165+
phantom: PhantomData,
166166
}
167167
}
168168

@@ -230,7 +230,7 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<CppRef<'_, U>> for CppRef
230230
#[repr(transparent)]
231231
pub struct CppMutRef<'a, T: ?Sized> {
232232
ptr: *mut T,
233-
phantom: PhantomData<&'a T>,
233+
phantom: PhantomData<&'a mut T>,
234234
}
235235

236236
impl<T: ?Sized> CppMutRef<'_, T> {
@@ -296,7 +296,7 @@ impl<'a, T> From<CppMutRef<'a, T>> for CppRef<'a, T> {
296296
fn from(mutable: CppMutRef<'a, T>) -> Self {
297297
Self {
298298
ptr: mutable.ptr,
299-
phantom: mutable.phantom,
299+
phantom: PhantomData,
300300
}
301301
}
302302
}

0 commit comments

Comments
 (0)