title: How to resolve "expected (), found Result" when returning a custom result?
body: <p>I am creating a custom <code>Result</code> such that the the <code>Ok</code> value is generic, but I get the following error: </p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
    --&gt; src/main.rs:38:13
     |
  38 |             Err(Error::new(ErrorKind::Other, "Not a subset"))
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `std::result::Result`
     |
     = note: expected type `()`
                found type `std::result::Result&lt;_, std::io::Error&gt;`
  </code></pre>
  
  <p>With this code:</p>
  
  <pre><code>use std::io;
  use std::io::{Error, ErrorKind};
  
  pub type SubsetResult&lt;T&gt; = Result&lt;T, SubsetError&gt;;
  
  #[derive(Debug)]
  pub enum SubsetError {
      Io(io::Error),
  }
  
  impl From&lt;io::Error&gt; for SubsetError {
      fn from(err: io::Error) -&gt; SubsetError {
          SubsetError::Io(err)
      }
  }
  
  trait Subset {
      type T;
      fn is_subset(&amp;self, &amp;[i32]) -&gt; SubsetResult&lt;Self::T&gt;;
  }
  
  #[derive(Debug)]
  struct Set {
      dataset: Vec&lt;i32&gt;,
  }
  
  impl Subset for Set {
      type T = bool;
  
      // self is the superset
      fn is_subset(&amp;self, subset: &amp;[i32]) -&gt; SubsetResult&lt;Self::T&gt; {
          let mut concatedsets = Vec::new();
          concatedsets.extend_from_slice(self.dataset.as_slice());
          concatedsets.extend_from_slice(subset);
          concatedsets.sort();
          concatedsets.dedup();
          if concatedsets.len() != self.dataset.len() {
              Err(Error::new(ErrorKind::Other, "Not a subset"))
          }
          Ok(true)
      }
  }
  
  
  fn main() {
      let superset = Set { dataset: vec![1, 2, 3, 4, 5] };
      let subset = vec![1, 2, 4];
      let result = superset.is_subset(subset.as_slice()).unwrap();
      println!("{}", result);
  
  }
  </code></pre>
  
  <p>(<a href="https://play.rust-lang.org/?gist=88d6c49a6fb15982312a1c1b5867da29&amp;version=stable" rel="noreferrer">Playground</a>)</p>