From f5b2dde2733c7e1ac7695490011980b4a0c12798 Mon Sep 17 00:00:00 2001 From: Pauan Date: Tue, 18 Sep 2018 00:50:07 -1000 Subject: [PATCH] Re-enabling the slice impls for MultiStr --- src/dom.rs | 9 +++++---- src/traits.rs | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/dom.rs b/src/dom.rs index c8c0ef1..8f27180 100644 --- a/src/dom.rs +++ b/src/dom.rs @@ -1094,9 +1094,8 @@ mod tests { .style_signal(&*FOO, always(&*FOO)) .style_signal(Box::new("foo".to_owned()), always(Box::new("bar".to_owned()))) - //.style_signal(vec!["-moz-foo", "-webkit-foo", "foo"].as_slice(), always("bar")) - //.style_signal(vec!["-moz-foo", "-webkit-foo", "foo"].as_slice(), always("bar".to_owned())) - //.style_signal(vec!["-moz-foo", "-webkit-foo", "foo"].as_slice(), always("bar".to_owned()).map(|x| RefFn::new(x, |x| x.as_str()))) + .style(vec!["-moz-foo", "-webkit-foo", "foo"].as_slice(), vec!["bar"].as_slice()) + .style_signal(RefFn::new(vec!["-moz-foo", "-webkit-foo", "foo"], |x| x.as_slice()), always(RefFn::new(vec!["bar"], |x| x.as_slice()))) .style_signal(["-moz-foo", "-webkit-foo", "foo"], always("bar")) .style_signal(["-moz-foo", "-webkit-foo", "foo"], always("bar".to_owned())) @@ -1104,7 +1103,9 @@ mod tests { .style_signal(["-moz-foo", "-webkit-foo", "foo"], always(["bar", "qux"])) .style_signal(["-moz-foo", "-webkit-foo", "foo"], always(["bar".to_owned(), "qux".to_owned()])) - //.style_signal(["-moz-foo", "-webkit-foo", "foo"], always(("bar".to_owned(), "qux".to_owned())).map(|x| RefFn::new(x, |x| [x.0.as_str(), x.1.as_str()]))) + + //.style_signal(["-moz-foo", "-webkit-foo", "foo"], always(AsSlice::new(["foo", "bar"]))) + //.style_signal(["-moz-foo", "-webkit-foo", "foo"], always(("bar".to_owned(), "qux".to_owned())).map(|x| RefFn::new(x, |x| AsSlice::new([x.0.as_str(), x.1.as_str()])))) .style_signal("foo", always(Some("bar"))) .style_signal("foo", always(Some("bar".to_owned()))) diff --git a/src/traits.rs b/src/traits.rs index af184a7..e2ee02a 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -98,20 +98,20 @@ impl MultiStr for A where A: AsStr { } // TODO it would be great to use IntoIterator instead, and then we can replace the array implementations with it -/*impl<'a, A> MultiStr for &'a [A] where A: AsStr { +impl<'a, A> MultiStr for &'a [A] where A: AsStr { #[inline] fn any(&self, mut f: F) -> bool where F: FnMut(&str) -> bool { self.iter().any(|x| f(x.as_str())) } -}*/ +} // TODO it would be great to use IntoIterator or Iterator instead -/*impl<'a, A, C> MultiStr for RefFn where C: Fn(&A) -> &[&'a str] { +impl<'a, A, C> MultiStr for RefFn where C: Fn(&A) -> &[&'a str] { #[inline] fn any(&self, mut f: F) -> bool where F: FnMut(&str) -> bool { self.call_ref().iter().any(|x| f(x)) } -}*/ +} macro_rules! array_multi_str { ($size:expr) => {