Adding in AsStr support for Cow

This commit is contained in:
Pauan 2022-04-12 10:06:40 -07:00
parent 0011fa682a
commit 623c896d80
1 changed files with 13 additions and 0 deletions

View File

@ -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<A, F>(&self, f: F) -> A where F: FnOnce(&str) -> A {
f(&*self)
}
}
impl<A, C> AsStr for RefFn<A, str, C> where C: Fn(&A) -> &str {
#[inline]
fn as_str(&self) -> &str {