rust: sync: implement `AsRef<T>` for `Arc<T>`
[linux-block.git] / rust / kernel / sync / arc.rs
index b03d84f7ce87525b83f573b5ddb02d7688543b9d..ace478442998a48454f0c1c326ee51dbaea59c73 100644 (file)
@@ -264,6 +264,12 @@ impl<T: ?Sized> Deref for Arc<T> {
     }
 }
 
+impl<T: ?Sized> AsRef<T> for Arc<T> {
+    fn as_ref(&self) -> &T {
+        self.deref()
+    }
+}
+
 impl<T: ?Sized> Clone for Arc<T> {
     fn clone(&self) -> Self {
         // INVARIANT: C `refcount_inc` saturates the refcount, so it cannot overflow to zero.