Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Fix "extra mut" warning
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 12, 2019
1 parent c0adf58 commit ce720f2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> Uninitialized for Boxed<T, MM> {
unsafe fn uninitialized() -> Self {
Boxed {
inner: {
let mut inner = Box::<T>::new(mem::MaybeUninit::zeroed().assume_init());
MM::init(&mut *inner);
let mut inner = Box::new(mem::MaybeUninit::zeroed());
MM::init(inner.as_mut_ptr());

AnyBox::Native(inner)
AnyBox::Native(Box::new(inner.assume_init()))
},
_dummy: PhantomData,
}
Expand Down
17 changes: 11 additions & 6 deletions src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,12 +1438,13 @@ impl<T: ObjectType> ObjectExt for T {

fn downgrade(&self) -> WeakRef<T> {
unsafe {
let w = WeakRef(Box::new(mem::MaybeUninit::zeroed().assume_init()), PhantomData);
let mut w = Box::new(mem::MaybeUninit::zeroed());
gobject_sys::g_weak_ref_init(
mut_override(&*w.0),
mut_override((&mut *w).as_mut_ptr()),
self.as_object_ref().to_glib_none().0,
);
w

WeakRef(Box::new((&mut *w).assume_init()), PhantomData)
}
}

Expand Down Expand Up @@ -1532,9 +1533,13 @@ pub struct WeakRef<T: ObjectType>(Box<gobject_sys::GWeakRef>, PhantomData<*const
impl<T: ObjectType> WeakRef<T> {
pub fn new() -> WeakRef<T> {
unsafe {
let w = WeakRef(Box::new(mem::MaybeUninit::zeroed().assume_init()), PhantomData);
gobject_sys::g_weak_ref_init(mut_override(&*w.0), ptr::null_mut());
w
let mut w = Box::new(mem::MaybeUninit::zeroed());
gobject_sys::g_weak_ref_init(
(&mut *w).as_mut_ptr(),
ptr::null_mut(),
);

WeakRef(Box::new((&mut *w).assume_init()), PhantomData)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/time_val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ impl<'a> ToGlibPtrMut<'a, *mut glib_sys::GTimeVal> for TimeVal {

impl Uninitialized for TimeVal {
unsafe fn uninitialized() -> TimeVal {
mem::MaybeUninit::zeroed().assume_init()
mem::zeroed()
}
}
4 changes: 2 additions & 2 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Value {
}

#[doc(hidden)]
pub fn into_raw(mut self) -> gobject_sys::GValue {
pub fn into_raw(self) -> gobject_sys::GValue {
unsafe {
let ret = ptr::read(&self.0);
mem::forget(self);
Expand Down Expand Up @@ -273,7 +273,7 @@ impl From<SendValue> for Value {

impl Uninitialized for Value {
unsafe fn uninitialized() -> Value {
Value(mem::MaybeUninit::zeroed().assume_init(), PhantomData)
mem::zeroed()
}
}

Expand Down

0 comments on commit ce720f2

Please # to comment.