title: Is there a way to convert a trait reference to an object of another unconnected type?
body: <p>I have a collection of interfaces that are loaded dynamically from shared libraries. I want to be able to convert those <em>downcasted</em> interfaces to their original type (trait).</p>
  
  <pre><code>struct A {}
  fn abstract_a&lt;'l&gt;() -&gt; &amp;'l Any { return &amp;A{} }
  
  trait TargetTrait { fn some_method(); }
  impl TargetTrait for A { fn some_method() { println!("HELLO"); } }    
  
  fn main() {
      let x: &amp;Any = abstract_a();
      let y: &amp;TargetTrait = magic_conversion&lt;&amp;TargetTrait&gt; (x);
  }
  // question: does 'magic_conversion'(or 'dynamic_cast') exist? what is it?
  </code></pre>
  
  <p>While loading these is not a problem, I have no idea how to get <em>target</em> functionality with such interface. In other words:</p>
  
  <pre><code>/* simplified for readability */
  // this part is known
  let some_lib = loadlib("path/to/lib.so")
  let some_interface: &amp;Any = some_lib.loadfunc&lt;&amp;Any&gt;("constructor_func")()
      /* loader does not know what target type constructor has, so it presumes 'Any' */
  
  // the problem:
  let dependent_class = Some(class)
  dependent_class.graphics = dynamic_cast&lt;IGraphics&gt;(some_interface)
  </code></pre>
  
  <p>In this example, <code>dependent_class</code> uses an extern interface and does not care about handling libloading and all of that complicated stuff.
  If there is another way to achieve my goal, I would also be very happy to see it, but the only solution I came up with is 'dynamic_cast'</p>