mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
impl Borrow
and AsRef
for CowArc
(#11616)
# Objective - Allow `HashMap<Cow<'_, T>, _>` to use `&T` as key for `HashMap::get` - Makes `CowArc` more like `Cow` ## Solution Implements `Borrow<T>` and `AsRef<T>` for `CowArc<T>`.
This commit is contained in:
parent
6b40b6749e
commit
4b7ef44bb4
1 changed files with 15 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
use std::{
|
||||
borrow::Borrow,
|
||||
fmt::{Debug, Display},
|
||||
hash::Hash,
|
||||
ops::Deref,
|
||||
|
@ -37,6 +38,20 @@ impl<'a, T: ?Sized> Deref for CowArc<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, T: ?Sized> Borrow<T> for CowArc<'a, T> {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &T {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: ?Sized> AsRef<T> for CowArc<'a, T> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &T {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: ?Sized> CowArc<'a, T>
|
||||
where
|
||||
&'a T: Into<Arc<T>>,
|
||||
|
|
Loading…
Reference in a new issue