Adding in AsStr support for Cow
This commit is contained in:
parent
0011fa682a
commit
623c896d80
|
@ -1,3 +1,4 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
use crate::dom::RefFn;
|
use crate::dom::RefFn;
|
||||||
|
|
||||||
pub use crate::animation::AnimatedSignalVec;
|
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 {
|
impl<A, C> AsStr for RefFn<A, str, C> where C: Fn(&A) -> &str {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_str(&self) -> &str {
|
fn as_str(&self) -> &str {
|
||||||
|
|
Loading…
Reference in New Issue