Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions rocketmq/src/arc_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

#![allow(dead_code)]

use core::fmt;
use std::cell::SyncUnsafeCell;
use std::fmt::Debug;
use std::fmt::Formatter;
use std::hash::Hash;
use std::hash::Hasher;
use std::ops::Deref;
Expand Down Expand Up @@ -132,21 +135,21 @@
}
}

impl<T> AsRef<T> for ArcMut<T> {
impl<T: ?Sized> AsRef<T> for ArcMut<T> {
#[inline]
fn as_ref(&self) -> &T {
unsafe { &*self.inner.get() }
}
}

impl<T> AsMut<T> for ArcMut<T> {
impl<T: ?Sized> AsMut<T> for ArcMut<T> {
#[inline]
fn as_mut(&mut self) -> &mut T {
unsafe { &mut *self.inner.get() }
}
}

impl<T> Deref for ArcMut<T> {
impl<T: ?Sized> Deref for ArcMut<T> {
type Target = T;

#[inline]
Expand All @@ -155,7 +158,7 @@
}
}

impl<T> DerefMut for ArcMut<T> {
impl<T: ?Sized> DerefMut for ArcMut<T> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
self.as_mut()
Expand Down Expand Up @@ -213,6 +216,12 @@
}
}

impl<T: ?Sized + Debug> std::fmt::Debug for ArcMut<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fmt::Debug::fmt(&**self, f)
}

Check warning on line 222 in rocketmq/src/arc_mut.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq/src/arc_mut.rs#L220-L222

Added lines #L220 - L222 were not covered by tests
}

#[cfg(test)]
mod arc_cell_wrapper_tests {
use std::sync::Arc;
Expand Down
Loading