These are chat archives for rust-lang/rust

22nd
Aug 2018
Sylwester Rąpała
@xoac
Aug 22 2018 16:09
Hi guys anther error that I don't understand:
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
  --> src/fogger.rs:43:6
   |
43 | impl<T: DeserializeOwned> Stream for MsgPackJournalTail {
   |      ^ unconstrained type parameter

error: aborting due to previous error
and the code:
>>impl<T: DeserializeOwned> Stream for MsgPackJournalTail {
      type Item = T;
      type Error = Error;
      fn poll(&mut self) -> Result<Async<Option<Self::Item>>, Self::Error> {
          let bytes = try_ready!(self.inner.poll());
          match rmp_serde::from_slice::<T>(&bytes) {
              Ok(ele) => Ok(Async::Read(Some(ele))),
              Err(err) => {                    
                  if self.skip_des_error {     
                      error!("Item in journal is corrupted! Err {:?}", err);
                      Ok(Async::NotReady)      
                  } else {                     
                      Err(Error::MsgPackDesError(err))
                  }                            
              }                                
          }                              
      }                                  
  }
I think I see.. I should use PhantomData to for MsgPackJournalTail to hold type I use
Denis Lisov
@tanriol
Aug 22 2018 17:26
If the type is per-stream, yes, you should :-)