Last active
November 30, 2015 01:26
-
-
Save ExpHP/8b2c212d5cdf9483060a to your computer and use it in GitHub Desktop.
trait bounds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/math.rs:328:45: 328:61 error: no method named `pointwise_mul` found for type `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32 + 'static>>>` in the current scope | |
src/math.rs:328 let a = a.clone().pointwise_mul(a.clone()).pointwise_mul(a); | |
^~~~~~~~~~~~~~~~ | |
src/math.rs:328:45: 328:61 note: the method `pointwise_mul` exists but the following trait bounds were not satisfied: `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : math::GetValueIter`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : math::SparseSparseOps<_>`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>> : iter::SparseIterator`, `Box<core::ops::FnMut((u32, u32)) -> u32> : core::ops::FnMut<((u32, u32),)>`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>> : iter::SparseIterator`, `Box<core::ops::FnMut((u32, u32)) -> u32> : core::ops::FnMut<((u32, u32),)>`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>> : iter::SparseIterator`, `Box<core::ops::FnMut((u32, u32)) -> u32> : core::ops::FnMut<((u32, u32),)>`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>> : iter::SparseIterator`, `Box<core::ops::FnMut((u32, u32)) -> u32> : core::ops::FnMut<((u32, u32),)>`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : math::GetValueIter`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : math::SparseSparseOps<_>`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `&iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : math::GetValueIter`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : math::SparseSparseOps<_>`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::ShapedSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::UniqueSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SortedSparseIterator`, `&mut iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : iter::SparseIterator` | |
src/math.rs:328:45: 328:61 help: items from traits can only be used if the trait is implemented and in scope; the following trait defines an item `pointwise_mul`, perhaps you need to implement it: | |
src/math.rs:328:45: 328:61 help: candidate #1: `math::PointwiseMul` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl<A:GetValueIter, B:GetValueIter<Value=<A as GetValueIter>::Value>> | |
PointwiseMul<B> for A | |
where <A as GetValueIter>::Value: Mul<<B as GetValueIter>::Value,Output=<A as GetValueIter>::Value>, | |
A: SparseSparseOps<B>, | |
B: Shape, | |
{ | |
type Output = | |
::iter::Shaped< | |
::iter::SparseMap< | |
::iter::SparseIntersection< | |
<A as GetValueIter>::Output, | |
<B as GetValueIter>::Output, | |
>, | |
// PROBLEMATIC LINE vvv | |
Box<FnMut((<A as GetValueIter>::Value, <B as GetValueIter>::Value)) -> <A as GetValueIter>::Value>, | |
>>; | |
fn pointwise_mul(self, rhs: B) -> Self::Output { | |
assert_eq!(self.dim(), rhs.dim()); | |
let dim = self.dim(); | |
let s = self.get_value_iter(); | |
let r = rhs.get_value_iter(); | |
s.sparse_intersection(r) | |
.sparse_map(MulFn) // FIXME replace with closure | |
.as_shaped(dim) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct MulFn; | |
impl<T:Mul<U>,U> FnOnce<((T,U),)> for MulFn { | |
type Output = <T as Mul<U>>::Output; | |
#[inline] extern "rust-call" fn call_once(self, ((x,y),): ((T,U),)) -> Self::Output { x * y } | |
} | |
impl<T:Mul<U>,U> FnMut<((T,U),)> for MulFn { | |
#[inline] extern "rust-call" fn call_mut(&mut self, ((x,y),): ((T,U),)) -> Self::Output { x * y } | |
} | |
impl<A:GetValueIter, B:GetValueIter<Value=<A as GetValueIter>::Value>> | |
PointwiseMul<B> for A | |
where <A as GetValueIter>::Value: Mul<<B as GetValueIter>::Value,Output=<A as GetValueIter>::Value>, | |
A: SparseSparseOps<B>, | |
B: Shape, | |
{ | |
type Output = | |
::iter::Shaped< | |
::iter::SparseMap< | |
::iter::SparseIntersection< | |
<A as GetValueIter>::Output, | |
<B as GetValueIter>::Output, | |
>, | |
MulFn, | |
>>; | |
fn pointwise_mul(self, rhs: B) -> Self::Output { | |
assert_eq!(self.dim(), rhs.dim()); | |
let dim = self.dim(); | |
let s = self.get_value_iter(); | |
let r = rhs.get_value_iter(); | |
s.sparse_intersection(r) | |
.sparse_map(Box::new(MulFn)) // FIXME replace with closure | |
.as_shaped(dim) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment