<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Dmitry Popov</title>
  <link>https://thedeemon.dreamwidth.org/</link>
  <description>Dmitry Popov - Dreamwidth Studios</description>
  <lastBuildDate>Thu, 12 Sep 2019 10:18:10 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>thedeemon</lj:journal>
  <lj:journaltype>personal</lj:journaltype>
  <image>
    <url>https://v2.dreamwidth.org/10868107/2634070</url>
    <title>Dmitry Popov</title>
    <link>https://thedeemon.dreamwidth.org/</link>
    <width>100</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>https://thedeemon.dreamwidth.org/134543.html</guid>
  <pubDate>Thu, 12 Sep 2019 10:18:10 GMT</pubDate>
  <title>о гарантиях</title>
  <link>https://thedeemon.dreamwidth.org/134543.html</link>
  <description>&lt;pre&gt;
fn helper&amp;lt;&apos;a, &apos;b, T&amp;gt;(_: &amp;&apos;a &amp;&apos;b (), v: &amp;&apos;b T) -&amp;gt; &amp;&apos;a T { v }

/// Turn any `&amp;T` into a `&amp;&apos;static T`. May introduce undefined behavior.
pub fn make_static&amp;lt;&apos;a, T&amp;gt;(input: &amp;&apos;a T) -&amp;gt; &amp;&apos;static T {
    let f: fn(_, &amp;&apos;a T) -&amp;gt; &amp;&apos;static T = helper;
    f(&amp;&amp;(), input)
}
&lt;/pre&gt;&lt;br /&gt;(&lt;a href=&quot;https://github.com/NieDzejkob/fake-static&quot;&gt;отсюда&lt;/a&gt;)&lt;br /&gt;Не ожидал, что так просто. Безо всякого unsafe берем и превращаем &quot;одолженную&quot; ссылку на временное значение в &quot;вечную&quot;, с соответствующими use-after-free последствиями. А просто дырка в borrow checker&apos;e, и давно уже, все никак не залатают.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=thedeemon&amp;ditemid=134543&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://thedeemon.dreamwidth.org/134543.html</comments>
  <category>rust</category>
  <lj:security>public</lj:security>
  <lj:reply-count>6</lj:reply-count>
</item>
</channel>
</rss>
