From 623c896d80abf59b35d08fe8d023a81c612a19ad Mon Sep 17 00:00:00 2001 From: Pauan Date: Tue, 12 Apr 2022 10:06:40 -0700 Subject: [PATCH] Adding in AsStr support for Cow --- src/traits.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/traits.rs b/src/traits.rs index 49b8d9c..a6f6b32 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow; use crate::dom::RefFn; pub use crate::animation::AnimatedSignalVec; @@ -85,6 +86,18 @@ impl<'a> AsStr for &'a str { } } +impl<'a> AsStr for Cow<'a, str> { + #[inline] + fn as_str(&self) -> &str { + &*self + } + + #[inline] + fn with_str(&self, f: F) -> A where F: FnOnce(&str) -> A { + f(&*self) + } +} + impl AsStr for RefFn where C: Fn(&A) -> &str { #[inline] fn as_str(&self) -> &str {