<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title> - rust</title>
    <subtitle>Personal Website and Blog of Manuel Bucher.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://manuelbucher.com/tags/rust/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://manuelbucher.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2025-07-10T00:00:00+00:00</updated>
    <id>https://manuelbucher.com/tags/rust/atom.xml</id>
    <entry xml:lang="en">
        <title>Integrating a Rust library into Gecko</title>
        <published>2025-07-10T00:00:00+00:00</published>
        <updated>2025-07-10T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://manuelbucher.com/blog/rust-gecko/"/>
        <id>https://manuelbucher.com/blog/rust-gecko/</id>
        
        <content type="html" xml:base="https://manuelbucher.com/blog/rust-gecko/">&lt;p&gt;Integrating a Rust library to Gecko &#x2F; Firefox is unexpectedly easy, but Rust adoption varies significantly between teams.
I started in the Firefox networking Team &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;wiki.mozilla.org&#x2F;Necko&quot;&gt;Necko&lt;&#x2F;a&gt;, which has a few Rust components like the HTTP&#x2F;3 stack &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;mozilla&#x2F;necko&quot;&gt;neqo&lt;&#x2F;a&gt; or the URL implementation.
After switching to &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;wiki.mozilla.org&#x2F;Privacy&quot;&gt;Privacy &#x2F; Anti-Tracking team&lt;&#x2F;a&gt; I&#x27;m now in a team that has no Rust code at all.
The interest for Rust components is there, but usually projects are started in C++ due to all code being in C++.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rust-in-gecko&quot;&gt;Rust in Gecko&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;4e6.github.io&#x2F;firefox-lang-stats&#x2F;&quot;&gt;&lt;img src=&quot;&#x2F;img&#x2F;2025-07-08-firefox-lang-stats.png&quot; alt=&quot;Pie chart with language usage&quot; &#x2F;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Looking at current language stats, we can see that Rust is currently at around 12% of Firefox code with almost 5 million lines of code.
This is not neglectable, but falls short behind C &#x2F; C++ and also JavaScript.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;&#x2F;strong&gt; Using tokei with &lt;code&gt;--exclude=third_party&lt;&#x2F;code&gt; suggests Rust has about 8% of the LOC of C++ for code written in mozilla-firefox directly. Not 50% as this diagram might suggest. (feedback after lightning talk)&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;error-categories-rules-out-by-rust&quot;&gt;Error categories rules out by Rust&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use after free bugs&lt;&#x2F;strong&gt;: No more &lt;code&gt;kungFuDeathGrip&lt;&#x2F;code&gt; security fixes to extend the lifetime of an object.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Data races&lt;&#x2F;strong&gt;: No more forgetting to question &quot;Do I need to lock a Mutex to access this variable?&quot;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Nullptr dereferences&lt;&#x2F;strong&gt;: Call by pointer is very common in C++, especially in idl interfaces. &quot;Can this pointer I’ve got passed be null?&quot; is now answered by the Rust type system.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Iterator invalidation&lt;&#x2F;strong&gt;: Another big class of errors. In Gecko this is also &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;searchfox.org&#x2F;mozilla-central&#x2F;rev&#x2F;578d9c83f046d8c361ac6b98b297c27990d468fd&#x2F;xpcom&#x2F;ds&#x2F;ArrayIterator.h#40-42&quot;&gt;memory safe for nsTArray&lt;&#x2F;a&gt;, but wrong code.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Other undefined behavior&lt;&#x2F;strong&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;other-rusty-reasons&quot;&gt;Other Rusty reasons&lt;&#x2F;h2&gt;
&lt;p&gt;In my opinion, Rust is just a very well-designed language.
It has great documentation infrastructure and awesome compiler errors aiding you in writing safe code.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;case-study-riir-copy-clean-link&quot;&gt;Case Study: RIIR &quot;Copy Clean Link&quot;&lt;&#x2F;h2&gt;
&lt;p&gt;The patch for the case study can be found in &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;phabricator.services.mozilla.com&#x2F;D225390&quot;&gt;D225390&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Almost always you probably want to split up the library into two parts:&lt;&#x2F;p&gt;
&lt;p&gt;One crate for functionality and bindings.
The functionality crate can be developed out-of-tree. In this example I&#x27;m going to have the crate be developed in-tree.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;add-crate-directories-to-moz-build&quot;&gt;Add crate directories to moz.build&lt;&#x2F;h3&gt;
&lt;p&gt;Add directory where the crates are located need to be included in the parent moz.build:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #24292E; background-color: #FFFFFF;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;DIRS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; +=&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #032F62;&quot;&gt;    &amp;quot;urlstrip&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #032F62;&quot;&gt;    &amp;quot;urlstrip_glue&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;functionality-crate&quot;&gt;Functionality crate&lt;&#x2F;h3&gt;
&lt;p&gt;The crate implementing the logic with no dependency on xpcom types simply needs to have a single-line (plus license text) &lt;code&gt;moz.build&lt;&#x2F;code&gt; next to the &lt;code&gt;Cargo.toml&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #24292E; background-color: #FFFFFF;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;FINAL_LIBRARY&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #032F62;&quot;&gt; &amp;quot;xul&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;&#x2F;strong&gt; To combat build failue you need to regenerate the &lt;code&gt;Cargo.toml&lt;&#x2F;code&gt; by running &lt;code&gt;.&#x2F;mach vendor rust --allow-dirty&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h3 id=&quot;cbindgen-xpcom-bindings-crate&quot;&gt;cbindgen &#x2F; XPCOM bindings crate&lt;&#x2F;h3&gt;
&lt;p&gt;You need a few more lines for the bindings crate to autogenerate a C++ header with cbindgen.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #24292E; background-color: #FFFFFF;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;FINAL_LIBRARY&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #032F62;&quot;&gt; &amp;quot;xul&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;EXPORTS&lt;&#x2F;span&gt;&lt;span&gt;.mozilla&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; +=&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #032F62;&quot;&gt;    &amp;quot;UrlStrip.h&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt; CONFIG&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #032F62;&quot;&gt;&amp;quot;COMPILE_ENVIRONMENT&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;]:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    CbindgenHeader(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #032F62;&quot;&gt;        &amp;quot;UrlStrip_ffi.h&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #E36209;&quot;&gt;        inputs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #032F62;&quot;&gt;&amp;quot;&#x2F;toolkit&#x2F;components&#x2F;antitracking&#x2F;urlstrip_glue&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    )&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;    EXPORTS&lt;&#x2F;span&gt;&lt;span&gt;.mozilla&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; +=&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #032F62;&quot;&gt;        &amp;quot;!UrlStrip_ffi.h&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You can depend on &lt;code&gt;nsstring&lt;&#x2F;code&gt; and other &lt;code&gt;xpcom&lt;&#x2F;code&gt; crates. However, you &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;firefox-source-docs.mozilla.org&#x2F;testing-rust-code&#x2F;index.html#rust-tests:~:text=Rust%20tests%20have%20one%20major%20restriction%3A%20they%20cannot%20link%20against%20Gecko%20symbols%2E%20Therefore%2C%20Rust%20tests%20cannot%20be%20used%20for%20crates%20that%20use%20Gecko%20crates%20like%20nsstring%20and%20xpcom%2E&quot;&gt;won&#x27;t&lt;&#x2F;a&gt; be able to use Rust&#x27;s native &lt;code&gt;#[test]&lt;&#x2F;code&gt; directive. This is one of the reasons you likely really want to have the separation between the two crate types.&lt;&#x2F;p&gt;
&lt;p&gt;To configure cbindgen, get inspired by taking a look at &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;searchfox.org&#x2F;mozilla-central&#x2F;search?path=&amp;amp;q=cbindgen.toml&quot;&gt;other cbindgen.toml files&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;You also want to have somewhat nicer C++ headers around your autogenerated cbindgen header for C++ &lt;code&gt;UrlStrip.h&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #24292E; background-color: #FFFFFF;&quot;&gt;&lt;code data-lang=&quot;cpp&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;struct&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; UrlStrip&lt;&#x2F;span&gt;&lt;span&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;public:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; static void&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; Create&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt;UrlStrip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;**&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E36209;&quot;&gt; pThis&lt;&#x2F;span&gt;&lt;span&gt;) {&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; urlstrip_new&lt;&#x2F;span&gt;&lt;span&gt;(pThis); }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; void&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; Delete&lt;&#x2F;span&gt;&lt;span&gt;() {&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; urlstrip_drop&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;this&lt;&#x2F;span&gt;&lt;span&gt;); }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; void&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; Init&lt;&#x2F;span&gt;&lt;span&gt;() {&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; urlstrip_init&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;this&lt;&#x2F;span&gt;&lt;span&gt;); };&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; void&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; Uninit&lt;&#x2F;span&gt;&lt;span&gt;() {&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; urlstrip_uninit&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;this&lt;&#x2F;span&gt;&lt;span&gt;); };&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; nsresult Strip&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;const&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; nsACString&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E36209;&quot;&gt; aURI&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; nsCString&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;*&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E36209;&quot;&gt; aOutURI&lt;&#x2F;span&gt;&lt;span&gt;) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;   return&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; urlstrip_strip&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;this&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span&gt;aURI, aOutURI);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; bool&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; CanStrip&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;const&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; nsACString&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E36209;&quot;&gt; aURI&lt;&#x2F;span&gt;&lt;span&gt;) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;   return&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; urlstrip_canstrip&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #005CC5;&quot;&gt;this&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span&gt;aURI);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;private:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; UrlStrip&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; = delete&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; ~UrlStrip&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; = delete&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; UrlStrip&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;const&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; UrlStrip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; = delete&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; UrlStrip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;&amp;amp; operator&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;const&lt;&#x2F;span&gt;&lt;span style=&quot;color: #6F42C1;&quot;&gt; UrlStrip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; = delete&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;};&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Maybe &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;cxx.rs&quot;&gt;cxx&lt;&#x2F;a&gt; could ease with this in the future: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=1921139&quot;&gt;Bug 1921139 - Allow creating C++ bindings for Rust code with cxx&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;other-files-to-touch&quot;&gt;Other files to touch&lt;&#x2F;h3&gt;
&lt;p&gt;To use the Rust library from C++&#x2F;JS, it must be linked. And for that you need to both add it as a dependency to &lt;code&gt;toolkit&#x2F;library&#x2F;rust&#x2F;shared&#x2F;Cargo.toml&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #24292E; background-color: #FFFFFF;&quot;&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;urlstrip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; { path&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #032F62;&quot;&gt; &amp;quot;..&#x2F;..&#x2F;..&#x2F;components&#x2F;antitracking&#x2F;urlstrip&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;urlstrip_glue&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; { path&lt;&#x2F;span&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #032F62;&quot;&gt; &amp;quot;..&#x2F;..&#x2F;..&#x2F;components&#x2F;antitracking&#x2F;urlstrip_glue&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And also important (due to still using 2015 rust edition) &lt;code&gt;extern crate&lt;&#x2F;code&gt; definitions in &lt;code&gt;toolkit&#x2F;library&#x2F;rust&#x2F;shared&#x2F;lib.rs&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #24292E; background-color: #FFFFFF;&quot;&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;extern crate&lt;&#x2F;span&gt;&lt;span&gt; urlstrip;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #D73A49;&quot;&gt;extern crate&lt;&#x2F;span&gt;&lt;span&gt; urlstrip_glue;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;done&quot;&gt;Done&lt;&#x2F;h2&gt;
&lt;p&gt;This is all.
Feel free to reach out to me if you have any questions!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;further-resources&quot;&gt;Further Resources&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;firefox-source-docs.mozilla.org&#x2F;build&#x2F;buildsystem&#x2F;rust.html&quot;&gt;https:&#x2F;&#x2F;firefox-source-docs.mozilla.org&#x2F;build&#x2F;buildsystem&#x2F;rust.html&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;firefox-source-docs.mozilla.org&#x2F;writing-rust-code&#x2F;&quot;&gt;https:&#x2F;&#x2F;firefox-source-docs.mozilla.org&#x2F;writing-rust-code&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ly8eupJOwbE&quot;&gt;Blog as Lightning Talk&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;pdf&#x2F;rust-gecko.pdf&quot;&gt;Lightning Talk slides&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;updates&quot;&gt;Updates&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;2025-07-10: Added note on Rust usage within gecko&lt;&#x2F;li&gt;
&lt;li&gt;2025-11-02: note on how to combat build failure after adding rust crate&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
</feed>
