title: Returning Result<(), Box<dyn Error>> in rust
body: <p>I have a function in golang -</p>
  <pre class="lang-golang prettyprint-override"><code>
  func (s *Server) getEnforcer(handle int) (*casbin.Enforcer, error) {
      if _, ok := s.enforcerMap[handle]; ok {
          return s.enforcerMap[handle], nil
      } else {
          return nil, errors.New(&quot;enforcer not found&quot;)
      }
  }
  
  </code></pre>
  <p>I am trying to implement this in rust. I have written this -</p>
  <pre class="lang-rs prettyprint-override"><code>impl Server {
      fn getEnforcer(&amp;mut self, handle: i32) -&gt; Result&lt;Enforcer, Box&lt;dyn Error&gt;&gt; {
          let e: Enforcer = self.enforcerMap[&amp;handle];
          // match ..
      }
  }
  </code></pre>
  <p>Can't figure out how to handle error.</p>