diff --git a/y-octo/src/doc/common/somr.rs b/y-octo/src/doc/common/somr.rs index 32a21fb..2b9e9b3 100644 --- a/y-octo/src/doc/common/somr.rs +++ b/y-octo/src/doc/common/somr.rs @@ -132,7 +132,7 @@ impl Somr { inner.data.as_mut().map(|x| x.get_mut()) } - pub fn get_mut_from_ref(&self) -> Option> { + pub unsafe fn get_mut_from_ref(&self) -> Option> { if !self.is_owned() || self.dangling() { return None; } @@ -141,7 +141,6 @@ impl Somr { inner.data_mut() } - #[allow(clippy::mut_from_ref)] pub unsafe fn get_mut_unchecked(&self) -> InnerRefMut<'_, T> { if self.dangling() { panic!("Try to visit Somr data that has already been dropped.") @@ -417,7 +416,7 @@ mod tests { // only owner can mut ref assert!(five_ref.get().is_some()); - assert!(five_ref.get_mut_from_ref().is_none()); + assert!(unsafe { five_ref.get_mut_from_ref() }.is_none()); drop(five); }); @@ -490,7 +489,9 @@ mod tests { fn test_inner_mut() { let five = Somr::new(5); fn add(a: &Somr, b: &Somr) { - a.get_mut_from_ref().map(|mut x| *x += *b.get().unwrap()).unwrap(); + unsafe { a.get_mut_from_ref() } + .map(|mut x| *x += *b.get().unwrap()) + .unwrap(); } add(&five, &five);