From ff214521f439814863a0eb3cc30f151485b44eb7 Mon Sep 17 00:00:00 2001 From: Tristan Guichaoua Date: Tue, 30 Jan 2024 09:43:34 +0100 Subject: [PATCH 1/2] impl `Borrow` for `CowArc` --- crates/bevy_utils/src/cow_arc.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/bevy_utils/src/cow_arc.rs b/crates/bevy_utils/src/cow_arc.rs index c78318323588b..b503d52cac5e5 100644 --- a/crates/bevy_utils/src/cow_arc.rs +++ b/crates/bevy_utils/src/cow_arc.rs @@ -1,4 +1,5 @@ use std::{ + borrow::Borrow, fmt::{Debug, Display}, hash::Hash, ops::Deref, @@ -37,6 +38,13 @@ impl<'a, T: ?Sized> Deref for CowArc<'a, T> { } } +impl<'a, T: ?Sized> Borrow for CowArc<'a, T> { + #[inline] + fn borrow(&self) -> &T { + self + } +} + impl<'a, T: ?Sized> CowArc<'a, T> where &'a T: Into>, From c3720243c0185a9e94cbbbcfbecd7fd6183084b3 Mon Sep 17 00:00:00 2001 From: Tristan Guichaoua Date: Tue, 30 Jan 2024 09:50:36 +0100 Subject: [PATCH 2/2] impl `AsRef` for `ArcCow` --- crates/bevy_utils/src/cow_arc.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/bevy_utils/src/cow_arc.rs b/crates/bevy_utils/src/cow_arc.rs index b503d52cac5e5..47eb7c05429b5 100644 --- a/crates/bevy_utils/src/cow_arc.rs +++ b/crates/bevy_utils/src/cow_arc.rs @@ -45,6 +45,13 @@ impl<'a, T: ?Sized> Borrow for CowArc<'a, T> { } } +impl<'a, T: ?Sized> AsRef for CowArc<'a, T> { + #[inline] + fn as_ref(&self) -> &T { + self + } +} + impl<'a, T: ?Sized> CowArc<'a, T> where &'a T: Into>,