Skip to content

Commit

Permalink
Implement AsRef and Borrow for Arc (#325)
Browse files Browse the repository at this point in the history
These traits are necessary to use the Arc in places that expect AsRef
and Borrow.

Signed-off-by: John Nunley <dev@notgull.net>
  • Loading branch information
notgull authored Aug 9, 2023
1 parent 0cdd453 commit 6838e8e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sync/arc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::rt;

use std::borrow::Borrow;
use std::pin::Pin;
use std::{mem, ops, ptr};

Expand Down Expand Up @@ -267,3 +268,15 @@ impl<T> From<T> for Arc<T> {
Arc::new(t)
}
}

impl<T: ?Sized> AsRef<T> for Arc<T> {
fn as_ref(&self) -> &T {
self
}
}

impl<T: ?Sized> Borrow<T> for Arc<T> {
fn borrow(&self) -> &T {
self
}
}

0 comments on commit 6838e8e

Please sign in to comment.