Skip to content

Commit 5e28f7c

Browse files
committed
Rename unchecked_refmut -> unchecked_mut
1 parent 98d810e commit 5e28f7c

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/pycell.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ where
2626
unsafe fn unchecked_ref(&self) -> &T {
2727
&*((&self) as *const &Self as *const _)
2828
}
29-
unsafe fn unchecked_refmut(&self) -> &mut T {
29+
unsafe fn unchecked_mut(&self) -> &mut T {
3030
&mut *((&self) as *const &Self as *const _ as *mut _)
3131
}
3232
}
@@ -64,7 +64,7 @@ unsafe impl<T: PyClass> PyObjectLayout<T> for PyCellInner<T> {
6464
unsafe fn unchecked_ref(&self) -> &T {
6565
&*self.value.get()
6666
}
67-
unsafe fn unchecked_refmut(&self) -> &mut T {
67+
unsafe fn unchecked_mut(&self) -> &mut T {
6868
&mut *self.value.get()
6969
}
7070
unsafe fn py_init(&mut self, value: T) {
@@ -202,8 +202,8 @@ unsafe impl<T: PyClass> PyObjectLayout<T> for PyCell<T> {
202202
unsafe fn unchecked_ref(&self) -> &T {
203203
self.inner.unchecked_ref()
204204
}
205-
unsafe fn unchecked_refmut(&self) -> &mut T {
206-
self.inner.unchecked_refmut()
205+
unsafe fn unchecked_mut(&self) -> &mut T {
206+
self.inner.unchecked_mut()
207207
}
208208
unsafe fn py_init(&mut self, value: T) {
209209
self.inner.value = ManuallyDrop::new(UnsafeCell::new(value));
@@ -273,11 +273,11 @@ where
273273
U: PyClass,
274274
{
275275
pub fn into_super(self) -> PyRef<'p, U> {
276-
let res = PyRef {
277-
inner: &self.inner.ob_base,
278-
};
279-
std::mem::forget(self); // Avoid drop
280-
res
276+
let PyRef { inner } = self;
277+
std::mem::forget(self);
278+
PyRef {
279+
inner: &inner.ob_base,
280+
}
281281
}
282282
}
283283

@@ -331,7 +331,7 @@ impl<'p, T: PyClass> PyRefMut<'p, T> {
331331
unsafe { self.inner.ob_base.unchecked_ref() }
332332
}
333333
pub fn as_super_mut(&'p mut self) -> &'p mut T::BaseType {
334-
unsafe { self.inner.ob_base.unchecked_refmut() }
334+
unsafe { self.inner.ob_base.unchecked_mut() }
335335
}
336336
}
337337

@@ -341,11 +341,11 @@ where
341341
U: PyClass,
342342
{
343343
pub fn into_super(self) -> PyRefMut<'p, U> {
344-
let res = PyRefMut {
345-
inner: &self.inner.ob_base,
346-
};
347-
std::mem::forget(self); // Avoid drop
348-
res
344+
let PyRefMut { inner } = self;
345+
std::mem::forget(self);
346+
PyRefMut {
347+
inner: &inner.ob_base,
348+
}
349349
}
350350
}
351351

@@ -361,7 +361,7 @@ impl<'p, T: PyClass> Deref for PyRefMut<'p, T> {
361361
impl<'p, T: PyClass> DerefMut for PyRefMut<'p, T> {
362362
#[inline]
363363
fn deref_mut(&mut self) -> &mut T {
364-
unsafe { self.inner.unchecked_refmut() }
364+
unsafe { self.inner.unchecked_mut() }
365365
}
366366
}
367367

src/type_object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub unsafe trait PyObjectLayout<T: PyTypeInfo> {
2222
unsafe fn py_init(&mut self, _value: T) {}
2323
unsafe fn py_drop(&mut self, _py: Python) {}
2424
unsafe fn unchecked_ref(&self) -> &T;
25-
unsafe fn unchecked_refmut(&self) -> &mut T;
25+
unsafe fn unchecked_mut(&self) -> &mut T;
2626
}
2727

2828
/// `T: PyObjectSizedLayout<U>` represents `T` is not a instance of

src/types/any.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ unsafe impl crate::type_object::PyObjectLayout<PyAny> for ffi::PyObject {
2727
unsafe fn unchecked_ref(&self) -> &PyAny {
2828
&*((&self) as *const &Self as *const _)
2929
}
30-
unsafe fn unchecked_refmut(&self) -> &mut PyAny {
30+
unsafe fn unchecked_mut(&self) -> &mut PyAny {
3131
&mut *((&self) as *const &Self as *const _ as *mut _)
3232
}
3333
}

src/types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ macro_rules! impl_layout {
6262
unsafe fn unchecked_ref(&self) -> &$name {
6363
&*((&self) as *const &Self as *const _)
6464
}
65-
unsafe fn unchecked_refmut(&self) -> &mut $name {
65+
unsafe fn unchecked_mut(&self) -> &mut $name {
6666
&mut *((&self) as *const &Self as *const _ as *mut _)
6767
}
6868
}

tests/test_gc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ fn inheritance_with_new_methods_with_drop() {
268268
let obj: &PyCell<SubClassWithDrop> = inst.try_into().unwrap();
269269
let mut obj_ref_mut = obj.borrow_mut();
270270
obj_ref_mut.data = Some(Arc::clone(&drop_called1));
271-
let super_ = obj_ref_mut.get_super_mut();
271+
let mut super_ = obj_ref_mut.into_super();
272272
super_.data = Some(Arc::clone(&drop_called2));
273273
}
274274

0 commit comments

Comments
 (0)