Help with a type error

I have the following function that fails to type check, but I'm not sure why it doesn't. Does anyone have any suggestions? There's no type error for b0.

pub async fn take_until<T, F>( gs : &mut GenState<T>, pred : F) -> Vec<u8>
      where T : Helper
          , F : Fn(u8,) -> bool
          , Result<(), T::Error> : RichResultWithNeverError<()>
          , Result<u8, T::Error> : RichResultWithNeverError<()> {
      let mut b0 : Result<u8,T::Error> = ...;
      let mut b : u8 = b0.safely_unwrap();
      ...
}

Here's the trait implementation:

impl<T> RichResultWithNeverError<T> for Result<T, NullHelperNeverError> {
   fn safely_unwrap(self) -> T { ... }
}

Here's the type error:

 |     let mut b : u8 = b0.safely_unwrap();
 |                 --   ^^^^^^^^^^^^^^^^^^ expected `u8`, found `()`

Thanks!

I just realized there's a typo in the second constraint. It should be Result<u8, T::Error> : RichResultWithNeverError<u8>.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.