<p dir="auto">It's needed for things like an <code class="notranslate">Any</code> type, or safe dynamic loading.</p>
<p dir="auto">It basically needs to be an generic intrinsic that returns some kind of data structure that uniquely identifies the generic type it has been instantiated with. Ideally it also includes information about the crate itself and it's meta data, so that two different named and/or versioned crates with the same type result in different <code class="notranslate">TypeID</code>s.</p>
<p dir="auto">Currently, the static pointers to type descriptors can be kinda used for this, but there is no guarantee that a type descriptor can not be duplicated, so using them for this purpose is incorrect.</p>
<p dir="auto">Possible usage could look like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fn same_types&lt;T, U&gt;() -&gt; bool {
    let type_id_t = intrinsics::type_id::&lt;T&gt;();
    let type_id_u = intrinsics::type_id::&lt;U&gt;();

    type_id_t == type_id_u
}

fn main() {
    assert!(same_types::&lt;uint, uint&gt;());

    let type_id = intrinsics::type_id::&lt;std::util::Void&gt;();
    assert!(type_id.path().to_str() == &quot;&lt;6df45e453&gt;::std::util::Void&quot;);
    assert!(type_id.crate().name() == &quot;std&quot;);
    assert!(type_id.crate().version() == &quot;1.0&quot;);
    assert!(type_id.crate().hash() == &quot;6df45e453&quot;);

}"><pre class="notranslate"><code class="notranslate">fn same_types&lt;T, U&gt;() -&gt; bool {
    let type_id_t = intrinsics::type_id::&lt;T&gt;();
    let type_id_u = intrinsics::type_id::&lt;U&gt;();

    type_id_t == type_id_u
}

fn main() {
    assert!(same_types::&lt;uint, uint&gt;());

    let type_id = intrinsics::type_id::&lt;std::util::Void&gt;();
    assert!(type_id.path().to_str() == "&lt;6df45e453&gt;::std::util::Void");
    assert!(type_id.crate().name() == "std");
    assert!(type_id.crate().version() == "1.0");
    assert!(type_id.crate().hash() == "6df45e453");

}
</code></pre></div>
<p dir="auto">See also <a href="https://gist.github.com/Kimundi/6802198">https://gist.github.com/Kimundi/6802198</a> for some prototype implementation of a <code class="notranslate">TypeID</code> using type descriptors.</p>
<p dir="auto">I discussed this briefly with <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/aturon/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/aturon">@aturon</a>, but I thought I would submit an issue to track the discussion.</p>
<p dir="auto">I have been trying to implement an equivalent to Java's thread park / unpark using #[thread_local] but it requires being able to run some cleanup code when the thread exits. This currently isn't possible but should be with a little help from rust's thread support.</p>