<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>kart&#x27;s blog</title>
    <subtitle>Broadly interested in programming languages and systems programming.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://blog.vashishtha.in/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://blog.vashishtha.in"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2025-01-07T00:00:00+00:00</updated>
    <id>https://blog.vashishtha.in/atom.xml</id>
    <entry xml:lang="en">
        <title>Keymashed: motivating your internet by mashing your keyboard</title>
        <published>2025-01-07T00:00:00+00:00</published>
        <updated>2025-01-07T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.vashishtha.in/keymashed/"/>
        <id>https://blog.vashishtha.in/keymashed/</id>
        
        <content type="html" xml:base="https://blog.vashishtha.in/keymashed/">&lt;p&gt;Since making the internet faster is a hard research problem, keymashed instead worsens the internet and then eases up proportional to how fast you mash the keyboard. It features:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;an overengineered network protocol&lt;&#x2F;li&gt;
&lt;li&gt;a from-scratch video codec based on JPEG&lt;&#x2F;li&gt;
&lt;li&gt;humor&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The project README on &lt;a href=&quot;https:&#x2F;&#x2F;www.github.com&#x2F;kartva&#x2F;keymashed&quot;&gt;GitHub&lt;&#x2F;a&gt; contains all the detail - all some 2000 words of it.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>&quot;Why Rust&quot; - Presentation at Purdue Hackers</title>
        <published>2024-10-07T00:00:00+00:00</published>
        <updated>2024-10-07T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.vashishtha.in/why-rust/"/>
        <id>https://blog.vashishtha.in/why-rust/</id>
        
        <content type="html" xml:base="https://blog.vashishtha.in/why-rust/">&lt;p&gt;These are slides I used to present Rust to an audience that hadn&#x27;t interacted with Rust before. I&#x27;m putting these here since I&#x27;ve heard from a bunch of people they really liked the slides and the presentation.&lt;&#x2F;p&gt;
&lt;p&gt;I presented these at a session at &lt;a href=&quot;https:&#x2F;&#x2F;www.purduehackers.com&#x2F;&quot;&gt;Purdue Hackers&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;If you have trouble viewing the embed below, &lt;a href=&quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;why-rust&#x2F;why-rust.pdf&quot;&gt;you can use this link&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;embed src=&quot;&#x2F;why-rust&#x2F;why-rust.pdf&quot; width=&quot;100%&quot; height=&quot;800px&quot; type=&quot;application&#x2F;pdf&quot;&gt;</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Investigating a possible Linux bug: small-sized sbrk calls unexpectedly succeed despite low RLIMIT_AS</title>
        <published>2024-09-04T00:00:00+00:00</published>
        <updated>2024-09-04T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.vashishtha.in/small-sbrk-sizes-with-rlimit/"/>
        <id>https://blog.vashishtha.in/small-sbrk-sizes-with-rlimit/</id>
        
        <content type="html" xml:base="https://blog.vashishtha.in/small-sbrk-sizes-with-rlimit/">&lt;p&gt;This article documents the investigatory process in detail. Skip to &lt;a href=&quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;small-sbrk-sizes-with-rlimit&#x2F;#submitted-kernel-patch&quot;&gt;the patch&lt;&#x2F;a&gt; for a summary of the situation.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;background&quot;&gt;Background&lt;a class=&quot;zola-anchor&quot; href=&quot;#background&quot; aria-label=&quot;Anchor link for: background&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;I assume knowledge of the differences between the heap and the stack, along with experience using &lt;code&gt;malloc&lt;&#x2F;code&gt; to allocate memory.&lt;&#x2F;p&gt;
&lt;p&gt;Each process on Linux is given its own &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Virtual_address_space&quot;&gt;address space&lt;&#x2F;a&gt; with the layout:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+-----------+ &amp;lt;- Largest memory address (0xfffffffff..)
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|   Stack   | 
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+-----------+ &amp;lt;- stack pointer
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|           |
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|           | || stack grows down
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|           | \&#x2F;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|           |
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|           | &amp;lt;-- Empty space
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|           |
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|           | &#x2F;\
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|           | || heap grows up
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|           |
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+-----------+ &amp;lt;- process break
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|    Heap   | 
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+-----------+
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|    BSS    | &amp;lt;- Unitialized global data
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+-----------+
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|    data   | &amp;lt;- Initialized global data
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+-----------+
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;|    text   | &amp;lt;- Executable machine code
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+-----------+ &amp;lt;- Lowest memory address (0x000000000..)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;7908799&#x2F;xsh&#x2F;brk.html&quot;&gt;&lt;code&gt;sbrk&lt;&#x2F;code&gt; and &lt;code&gt;brk&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; are both functions that modify the &lt;em&gt;process break&lt;&#x2F;em&gt; to either grow or shrink the heap - thus changing the amount of memory that the program can access. They are commonly used to implement memory allocation inside &lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;7908799&#x2F;xsh&#x2F;malloc.html&quot;&gt;&lt;code&gt;malloc()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;c&quot; class=&quot;language-c z-code&quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-preprocessor z-include z-c&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-include z-c&quot;&gt;#include&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-other z-lt-gt z-include z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;unistd.h&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-storage z-type z-c&quot;&gt;int&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-c&quot;&gt;brk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-storage z-type z-c&quot;&gt;void&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-c&quot;&gt;addr&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-comment z-line z-double-slash z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; addr is the desired break address
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-storage z-type z-c&quot;&gt;void&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-c&quot;&gt;sbrk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-support z-type z-stdint z-c&quot;&gt;intptr_t&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-c&quot;&gt;incr&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-comment z-line z-double-slash z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; incr is the amount of bytes to grow&#x2F;shrink break by
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;a class=&quot;zola-anchor&quot; href=&quot;#introduction&quot; aria-label=&quot;Anchor link for: introduction&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;An assignment to implement a custom memory allocator in C has the &lt;code&gt;test_out_of_ram&lt;&#x2F;code&gt; test, which is &lt;em&gt;supposed&lt;&#x2F;em&gt; to ensure that the implementation
gracefully handles running out of heap memory.&lt;&#x2F;p&gt;
&lt;p&gt;The test does the following:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;It uses the &lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;007904975&#x2F;functions&#x2F;getrlimit.html&quot;&gt;&lt;code&gt;getrlimit&lt;&#x2F;code&gt; and &lt;code&gt;setrlimit&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; functions with the &lt;code&gt;RLIMIT_AS&lt;&#x2F;code&gt; parameter to restrict address space growth; artificially limiting the amount of memory that the program can access to test its behavior when out-of-memory. (we will discuss this further later on)&lt;&#x2F;li&gt;
&lt;li&gt;Since our malloc implementation allocates memory from &lt;code&gt;sbrk&lt;&#x2F;code&gt; in large chunks, the test allocates large amount of memory to nearly fill up existing chunks, guaranteeing that the next &lt;code&gt;my_malloc&lt;&#x2F;code&gt; invocation will cause a &lt;code&gt;sbrk&lt;&#x2F;code&gt; call.&lt;&#x2F;li&gt;
&lt;li&gt;It then calls &lt;code&gt;malloc&lt;&#x2F;code&gt; and asserts that it returned a &lt;code&gt;NULL&lt;&#x2F;code&gt; pointer, indicating an error.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;blockquote&gt;
&lt;p&gt;Step 3 listed above is implemented incorrectly; the test case erroneously calls &lt;code&gt;malloc&lt;&#x2F;code&gt; instead of &lt;code&gt;my_malloc&lt;&#x2F;code&gt; and ends up testing libc malloc&#x27;s behavior when out-of-memory instead of the custom implementation.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;pre data-linenos data-lang=&quot;c&quot; class=&quot;language-c z-code&quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-preprocessor z-include z-c&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-include z-c&quot;&gt;#include&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-include z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;my_malloc.h&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-preprocessor z-include z-c&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-include z-c&quot;&gt;#include&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-other z-lt-gt z-include z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;stdio.h&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-preprocessor z-include z-c&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-include z-c&quot;&gt;#include&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-other z-lt-gt z-include z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;stdlib.h&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-preprocessor z-include z-c&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-include z-c&quot;&gt;#include&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-other z-lt-gt z-include z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;sys&#x2F;resource.h&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;5&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-storage z-type z-c&quot;&gt;int&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-c&quot;&gt;main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-c&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-comment z-line z-double-slash z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; Limit address space size to 1 byte using setrlimit
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-storage z-type z-c&quot;&gt;struct&lt;&#x2F;span&gt; rlimit lim&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-variable z-function z-c&quot;&gt;getrlimit&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;RLIMIT_AS&lt;span class=&quot;z-punctuation z-separator z-c&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;lim&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    lim&lt;span class=&quot;z-punctuation z-accessor z-c&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-member z-c&quot;&gt;rlim_cur&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-c&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-variable z-function z-c&quot;&gt;setrlimit&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;RLIMIT_AS&lt;span class=&quot;z-punctuation z-separator z-c&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;lim&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-comment z-line z-double-slash z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; Alloc slightly less than arena size to guarantee
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-comment z-line z-double-slash z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; that next allocation requires allocating a new chunk by calling sbrk.
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-storage z-type z-c&quot;&gt;void&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt; p &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-variable z-function z-c&quot;&gt;my_malloc&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;ARENA_SIZE &lt;span class=&quot;z-keyword z-operator z-arithmetic z-c&quot;&gt;-&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-c&quot;&gt;3&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt; ALLOC_HEADER_SIZE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt; 
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-support z-function z-C99 z-c&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Mallocing an additional 8 bytes, which requires more memory from &lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;            &lt;span class=&quot;z-string z-quoted z-double z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;sbrk, but sbrk will fail&lt;span class=&quot;z-constant z-character z-escape z-c&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-comment z-line z-double-slash z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; This erroneously tests `malloc` instead of `my_malloc`.
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;21&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-storage z-type z-c&quot;&gt;void&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt; ptr &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-support z-function z-C99 z-c&quot;&gt;malloc&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-c&quot;&gt;8&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;22&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;23&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-keyword z-control z-c&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;ptr &lt;span class=&quot;z-keyword z-operator z-comparison z-c&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-c&quot;&gt;NULL&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-c&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;24&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;        &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-support z-function z-C99 z-c&quot;&gt;perror&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;SUCCESS: Malloc Failed&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;25&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-punctuation z-section z-block z-end z-c&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-c&quot;&gt;else&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-c&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;26&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;        &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-support z-function z-C99 z-c&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Malloc should have failed due to sbrk returning failure&lt;span class=&quot;z-constant z-character z-escape z-c&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-c&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;27&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-punctuation z-section z-block z-end z-c&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;28&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-c&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This test case normally passes, since libc &lt;code&gt;malloc&lt;&#x2F;code&gt; demonstrates correct behaviour.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;The extra-credit portion of the assignment involves using &lt;code&gt;LD_PRELOAD&lt;&#x2F;code&gt; to override the test&#x27;s calls to the &lt;code&gt;malloc&lt;&#x2F;code&gt; symbol with &lt;code&gt;my_malloc&lt;&#x2F;code&gt;. I got Chrome running on my memory allocator! Unfortunately, the test now fails. That is to say, &lt;code&gt;my_malloc&lt;&#x2F;code&gt; unexpectedly succeeds after setting rlimit.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;analysis&quot;&gt;Analysis&lt;a class=&quot;zola-anchor&quot; href=&quot;#analysis&quot; aria-label=&quot;Anchor link for: analysis&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;h2 id=&quot;analyzing-the-test-success&quot;&gt;Analyzing the test success&lt;a class=&quot;zola-anchor&quot; href=&quot;#analyzing-the-test-success&quot; aria-label=&quot;Anchor link for: analyzing-the-test-success&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Normally, when malloc is not overridden (and points to libc&#x27;s malloc), the following occurs on line 21 (&lt;code&gt;void * ptr = malloc(8)&lt;&#x2F;code&gt;):&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Mallocing an additional 8 bytes, which requires more memory from sbrk, but sbrk will fail
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Breakpoint 1, __GI___sbrk (increment=135168) at .&#x2F;misc&#x2F;sbrk.c:37
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;37    in .&#x2F;misc&#x2F;sbrk.c
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;(gdb) finish
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Run till exit from #0  __GI___sbrk (increment=135168) at .&#x2F;misc&#x2F;sbrk.c:37
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;__glibc_morecore (increment=&amp;lt;optimized out&amp;gt;) at .&#x2F;malloc&#x2F;morecore.c:30
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;30    .&#x2F;malloc&#x2F;morecore.c: No such file or directory.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Value returned is $1 = (void *) 0xffffffffffffffff
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;sbrk()&lt;&#x2F;code&gt; is called with a large increment size (135168 bytes for some reason). This returns -1 to indicate failure, because setrlimit restricts it from growing in size. This failure is propagated to libc &lt;code&gt;malloc&lt;&#x2F;code&gt;, which returns &lt;code&gt;NULL&lt;&#x2F;code&gt;. This is the expected behavior.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;analyzing-test-failure-when-malloc-my-malloc&quot;&gt;Analyzing test failure when &lt;code&gt;malloc -&amp;gt; my_malloc&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#analyzing-test-failure-when-malloc-my-malloc&quot; aria-label=&quot;Anchor link for: analyzing-test-failure-when-malloc-my-malloc&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;However, when &lt;code&gt;malloc&lt;&#x2F;code&gt; forwards to &lt;code&gt;my_malloc&lt;&#x2F;code&gt; (which is the case in the extra credit assignment), this call succeeds. Using gdb, we find:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Inside &lt;code&gt;my_malloc&lt;&#x2F;code&gt;: There is no existing chunk large enough to allocate the requested amount of memory.&lt;&#x2F;li&gt;
&lt;li&gt;We therefore allocate a new chunk of size 1024.&lt;&#x2F;li&gt;
&lt;li&gt;The call &lt;code&gt;sbrk(1024)&lt;&#x2F;code&gt; unexpectedly succeeds!&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Furthermore, if we call &lt;code&gt;sbrk(1024)&lt;&#x2F;code&gt; in gdb again, it succeeds... three more times. It fails every time after these four successful calls.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;explaining-sbrk-success&quot;&gt;Explaining sbrk() success&lt;a class=&quot;zola-anchor&quot; href=&quot;#explaining-sbrk-success&quot; aria-label=&quot;Anchor link for: explaining-sbrk-success&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The setrlimit documentation says the following (emphasis mine):&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;RLIMIT_AS&lt;&#x2F;strong&gt; &lt;br &#x2F;&gt;
This is the maximum size of a process&#x27; total available memory, &lt;strong&gt;in bytes&lt;&#x2F;strong&gt;. If this limit is exceeded, the &lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;7908799&#x2F;xsh&#x2F;brk.html&quot;&gt;&lt;code&gt;brk()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;7908799&#x2F;xsh&#x2F;malloc.html&quot;&gt;&lt;code&gt;malloc()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;7908799&#x2F;xsh&#x2F;mmap.html&quot;&gt;&lt;code&gt;mmap()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;7908799&#x2F;xsh&#x2F;sbrk.html&quot;&gt;&lt;code&gt;sbrk()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; functions will fail with &lt;em&gt;errno&lt;&#x2F;em&gt; set to [ENOMEM].&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Remember that we&#x27;ve set &lt;code&gt;RLIMIT_AS&lt;&#x2F;code&gt; to 1, which is a very low value. So low, that if the documentation is correct, &lt;code&gt;sbrk&lt;&#x2F;code&gt; should not succeed at incrementing even a single byte, since then the process&#x27; total available memory would exceed 1 byte.&lt;&#x2F;p&gt;
&lt;p&gt;Digging into glibc&#x27;s source code for &lt;code&gt;sbrk&lt;&#x2F;code&gt;, we find it internally calls &lt;code&gt;brk&lt;&#x2F;code&gt;. &lt;code&gt;brk&lt;&#x2F;code&gt;&#x27;s documentation says:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;int brk(void *addr);&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;code&gt;brk()&lt;&#x2F;code&gt; function sets the break value to &lt;em&gt;addr&lt;&#x2F;em&gt; and changes the allocated space accordingly.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;We now look into glibc&#x27;s implementation of &lt;code&gt;brk&lt;&#x2F;code&gt;,  but we find that &lt;a href=&quot;https:&#x2F;&#x2F;sourceware.org&#x2F;git&#x2F;?p=glibc.git;a=blob;f=sysdeps&#x2F;unix&#x2F;sysv&#x2F;linux&#x2F;brk.c;h=a0be43e4f9915297b2a7a2752cc1954589255b77;hb=HEAD&quot;&gt;glibc only contains a stub&lt;&#x2F;a&gt; that calls the Linux kernel&#x27;s brk syscall.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;c&quot; class=&quot;language-c z-code&quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;34&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-storage z-type z-c&quot;&gt;int&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;35&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-c&quot;&gt;__brk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-storage z-type z-c&quot;&gt;void&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-c&quot;&gt;*&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-c&quot;&gt;addr&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;36&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-c&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;37&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;  __curbrk &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-variable z-function z-c&quot;&gt;__brk_call&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;addr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;38&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;  &lt;span class=&quot;z-keyword z-control z-c&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;__curbrk &lt;span class=&quot;z-keyword z-operator z-comparison z-c&quot;&gt;&amp;lt;&lt;&#x2F;span&gt; addr&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;39&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-c&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;40&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;      &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-variable z-function z-c&quot;&gt;__set_errno&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;ENOMEM&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;41&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;      &lt;span class=&quot;z-keyword z-control z-flow z-return z-c&quot;&gt;return&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-c&quot;&gt;-&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-c&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;42&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;    &lt;span class=&quot;z-punctuation z-section z-block z-end z-c&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;43&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;44&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;  &lt;span class=&quot;z-keyword z-control z-flow z-return z-c&quot;&gt;return&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-c&quot;&gt;0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;45&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-c&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;To learn more, we&#x27;ll have to look at &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;torvalds&#x2F;linux&#x2F;blob&#x2F;55027e689933ba2e64f3d245fb1ff185b3e7fc81&#x2F;mm&#x2F;mmap.c#L178&quot;&gt;the source code for the &lt;code&gt;brk&lt;&#x2F;code&gt; syscall in the Linux kernel&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The kernel maintains memory in &lt;a href=&quot;https:&#x2F;&#x2F;docs.kernel.org&#x2F;admin-guide&#x2F;mm&#x2F;concepts.html&quot;&gt;pages&lt;&#x2F;a&gt;. We find that brk internally controls a variable that tracks where the current brk is, and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;torvalds&#x2F;linux&#x2F;blob&#x2F;55027e689933ba2e64f3d245fb1ff185b3e7fc81&#x2F;mm&#x2F;mmap.c#L3187&quot;&gt;allocates new pages&lt;&#x2F;a&gt; if the brk variable crosses a page boundary. Early on, we see that &lt;code&gt;newbrk&lt;&#x2F;code&gt; (the desired &lt;code&gt;brk&lt;&#x2F;code&gt; value) and &lt;code&gt;oldbrk&lt;&#x2F;code&gt; (the previous &lt;code&gt;brk&lt;&#x2F;code&gt; value) are rounded to a multiple of the page size and compared for equality.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;c&quot; class=&quot;language-c z-code&quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;z-source z-c&quot;&gt;newbrk &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-variable z-function z-c&quot;&gt;PAGE_ALIGN&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;brk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;oldbrk &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-variable z-function z-c&quot;&gt;PAGE_ALIGN&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;mm&lt;span class=&quot;z-punctuation z-accessor z-c&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt;brk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-keyword z-control z-c&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;oldbrk &lt;span class=&quot;z-keyword z-operator z-comparison z-c&quot;&gt;==&lt;&#x2F;span&gt; newbrk&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-c&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;  mm&lt;span class=&quot;z-punctuation z-accessor z-c&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt;brk &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; brk&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;  &lt;span class=&quot;z-keyword z-control z-flow z-goto z-c&quot;&gt;goto&lt;&#x2F;span&gt; success&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-meta z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-c&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;That is, if the new &lt;code&gt;brk&lt;&#x2F;code&gt; does not exceed a page boundary compared to the old &lt;code&gt;brk&lt;&#x2F;code&gt;, the &lt;code&gt;brk()&lt;&#x2F;code&gt; syscall reduces to merely increasing the value of &lt;code&gt;brk&lt;&#x2F;code&gt; variable without any other action. This is valid since the additional memory is already a part of an initialized page.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;the-answer&quot;&gt;The Answer&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-answer&quot; aria-label=&quot;Anchor link for: the-answer&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;The kernel checks for &lt;code&gt;RLIMIT_AS&lt;&#x2F;code&gt; setrlimit violations when &lt;code&gt;brk&lt;&#x2F;code&gt; requires allocating a new page. This does not occur if the &lt;code&gt;brk&lt;&#x2F;code&gt; change is small enough to be contained in one page.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;getconf PAGESIZE&lt;&#x2F;code&gt; on my machine returns 4096. This fits closely with &lt;code&gt;sbrk(1024)&lt;&#x2F;code&gt; never succeeding for more than four times before always failing. This is validated by going through the kernel source code and observing that &lt;code&gt;RLIMIT_AS&lt;&#x2F;code&gt; is checked in the &lt;code&gt;may_expand_vm&lt;&#x2F;code&gt; call which occurs after &lt;code&gt;brk&lt;&#x2F;code&gt; has been page-aligned.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;rlimit-as-and-rlimit-data-are-treated-differently&quot;&gt;RLIMIT_AS and RLIMIT_DATA are treated differently&lt;a class=&quot;zola-anchor&quot; href=&quot;#rlimit-as-and-rlimit-data-are-treated-differently&quot; aria-label=&quot;Anchor link for: rlimit-as-and-rlimit-data-are-treated-differently&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;While the above conclusion explains how &lt;code&gt;sbrk()&lt;&#x2F;code&gt; surprisingly succeeds despite a very low &lt;code&gt;RLIMIT_AS&lt;&#x2F;code&gt; limit, we find an interesting snippet of code from &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;torvalds&#x2F;linux&#x2F;commit&#x2F;1e624196f43c3a62122959e15c5f03572cdadb5d&quot;&gt;a commit made in April 2006&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;c&quot; class=&quot;language-c z-code&quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;224&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-comment z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;&#x2F;*&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;225&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-comment z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;*&lt;&#x2F;span&gt; Check against rlimit here. If this check is done later after the test
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;226&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-comment z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;*&lt;&#x2F;span&gt; of oldbrk with newbrk then it can escape the test and let the data
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;227&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-comment z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;*&lt;&#x2F;span&gt; segment grow beyond its set limit the in case where the limit is
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;228&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-comment z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;*&lt;&#x2F;span&gt; not page aligned -Ram Gupta
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;229&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-comment z-block z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-c&quot;&gt;*&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;230&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;rlim &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; current&lt;span class=&quot;z-punctuation z-accessor z-c&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt;signal&lt;span class=&quot;z-punctuation z-accessor z-c&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt;rlim&lt;span class=&quot;z-meta z-brackets z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-brackets z-begin z-c&quot;&gt;[&lt;&#x2F;span&gt;RLIMIT_DATA&lt;span class=&quot;z-punctuation z-section z-brackets z-end z-c&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-c&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-member z-c&quot;&gt;rlim_cur&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;231&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;&lt;span class=&quot;z-keyword z-control z-c&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;rlim &lt;span class=&quot;z-keyword z-operator z-comparison z-c&quot;&gt;&amp;lt;&lt;&#x2F;span&gt; RLIM_INFINITY &lt;span class=&quot;z-keyword z-operator z-arithmetic z-c&quot;&gt;&amp;amp;&amp;amp;&lt;&#x2F;span&gt; brk &lt;span class=&quot;z-keyword z-operator z-arithmetic z-c&quot;&gt;-&lt;&#x2F;span&gt; mm&lt;span class=&quot;z-punctuation z-accessor z-c&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt;start_data &lt;span class=&quot;z-keyword z-operator z-comparison z-c&quot;&gt;&amp;gt;&lt;&#x2F;span&gt; rlim&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;232&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;    &lt;span class=&quot;z-keyword z-control z-flow z-goto z-c&quot;&gt;goto&lt;&#x2F;span&gt; out&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;233&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;234&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;newbrk &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-variable z-function z-c&quot;&gt;PAGE_ALIGN&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;brk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;235&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-c&quot;&gt;oldbrk &lt;span class=&quot;z-keyword z-operator z-assignment z-c&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-variable z-function z-c&quot;&gt;PAGE_ALIGN&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-c&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;mm&lt;span class=&quot;z-punctuation z-accessor z-c&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt;brk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-c&quot;&gt;&lt;span class=&quot;z-meta z-group z-c&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-c&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-c&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;RLIMIT_DATA&lt;&#x2F;code&gt; is another value that can be manipulated using &lt;code&gt;setrlimit&lt;&#x2F;code&gt; that is very similar to &lt;code&gt;RLIMIT_AS&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;RLIMIT_DATA&lt;&#x2F;strong&gt; &lt;br &#x2F;&gt;
This is the maximum size of a process&#x27; data segment in bytes. If this limit is exceeded, the &lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;7908799&#x2F;xsh&#x2F;brk.html&quot;&gt;&lt;code&gt;brk()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;7908799&#x2F;xsh&#x2F;malloc.html&quot;&gt;&lt;code&gt;malloc()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;7908799&#x2F;xsh&#x2F;sbrk.html&quot;&gt;&lt;code&gt;sbrk()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; functions will fail with errno set to [ENOMEM].&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;&lt;code&gt;RLIMIT_DATA&lt;&#x2F;code&gt; is checked for &lt;code&gt;setrlimit&lt;&#x2F;code&gt; violations &lt;em&gt;before&lt;&#x2F;em&gt; page-aligning &lt;code&gt;brk&lt;&#x2F;code&gt; opposed to how &lt;code&gt;RLIMIT_AS&lt;&#x2F;code&gt; is checked &lt;em&gt;after&lt;&#x2F;em&gt; page-aligning &lt;code&gt;brk&lt;&#x2F;code&gt;. Substituting &lt;code&gt;RLIMIT_DATA&lt;&#x2F;code&gt; instead of &lt;code&gt;RLIMIT_AS&lt;&#x2F;code&gt; in the test case makes it behave expectedly.&lt;&#x2F;p&gt;
&lt;p&gt;This difference between two very similar settings bothered me, so...&lt;&#x2F;p&gt;
&lt;h1 id=&quot;submitted-kernel-patch&quot;&gt;Submitted Kernel Patch&lt;a class=&quot;zola-anchor&quot; href=&quot;#submitted-kernel-patch&quot; aria-label=&quot;Anchor link for: submitted-kernel-patch&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;I submitted a patch to the Linux kernel explaining the issue:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;From linux-mm  Mon Aug 19 00:35:00 2024
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;From: Kartavya Vashishtha &amp;lt;sendtokartavya () gmail ! com&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Date: Mon, 19 Aug 2024 00:35:00 +0000
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;To: linux-mm
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Subject: [PATCH] mm&#x2F;mmap.c: make brk() check RLIMIT_AS before page-aligning requested amount
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Message-Id: &amp;lt;66c29336.050a0220.395e9a.76bf () mx ! google ! com&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;X-MARC-Message: https:&#x2F;&#x2F;marc.info&#x2F;?l=linux-mm&amp;amp;m=172402763105157
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Currently, brk() only checks against RLIMIT_DATA when validating whether
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;the requested amount of memory is valid with respect to rlimit.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;RLIMIT_AS is checked later in the `may_expand_vm` call in `do_brk_flags`,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;but that call occurs after aligning the new brk to a page boundary, making
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;the following possible:
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;1. Allocate a non-page-sized amount of memory with brk()
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;2. brk() will internally page-align the requested amount, and allocate
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;the necessary amount of pages.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;3. Set RLIMIT_AS to 1 byte using setrlimit.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;4. Calling brk() again with a small increment (such that it does not
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;overflow to the next page) will succeed.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;This violates setrlimit RLIMIT_AS, since the call succeeds despite a
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;1 byte limit.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;The following code snippet reproduces this behavior:
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;```
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;int main() {
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        void * mem = malloc(4096);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        sbrk(32);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	    &#x2F;&#x2F; set RLIMIT_AS for the process&amp;#39;s address space to 1 byte
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        &#x2F;&#x2F; This causes all future calls to sbrk to fail
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        struct rlimit lim;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        getrlimit(RLIMIT_AS, &amp;amp;lim);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        lim.rlim_cur = 1;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        printf(&amp;quot;lim.rlim_max: %ld\n&amp;quot;, lim.rlim_max);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        setrlimit(RLIMIT_AS, &amp;amp;lim);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        printf(&amp;quot;Mallocing an additional 8 bytes, which requires more&amp;quot;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	           &amp;quot;memory from sbrk, but sbrk SHOULD fail\n&amp;quot;);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        void * ptr = sbrk(8);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        printf(&amp;quot;sbrk result: %p\n&amp;quot;, ptr);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        if (ptr != -1) {
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;                printf(&amp;quot;sbrk unexpectedly passed\n&amp;quot;);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        } else {
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;                printf(&amp;quot;sbrk expectedly failed\n&amp;quot;);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;        free(mem);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;```
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Signed-off-by: Kartavya Vashishtha &amp;lt;sendtokartavya@gmail.com&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;---
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; mm&#x2F;mmap.c | 4 ++--
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; 1 file changed, 2 insertions(+), 2 deletions(-)
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;diff --git a&#x2F;mm&#x2F;mmap.c b&#x2F;mm&#x2F;mmap.c
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;index d0dfc85b209b..5f7fc6591323 100644
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;--- a&#x2F;mm&#x2F;mmap.c
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+++ b&#x2F;mm&#x2F;mmap.c
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;@@ -253,8 +253,8 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; 	 * segment grow beyond its set limit the in case where the limit is
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; 	 * not page aligned -Ram Gupta
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; 	 *&#x2F;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;-	if (check_data_rlimit(rlimit(RLIMIT_DATA), brk, mm-&amp;gt;start_brk,
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;-			      mm-&amp;gt;end_data, mm-&amp;gt;start_data))
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+	if (check_data_rlimit(min(rlimit(RLIMIT_AS), rlimit(RLIMIT_DATA)),
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;+			      brk, mm-&amp;gt;start_brk, mm-&amp;gt;end_data, mm-&amp;gt;start_data))
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; 		goto out;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; 
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; 	newbrk = PAGE_ALIGN(brk);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;-- 
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I received the following response:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;From linux-mm  Mon Aug 19 09:06:06 2024
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;From: Lorenzo Stoakes &amp;lt;lorenzo.stoakes () oracle ! com&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Date: Mon, 19 Aug 2024 09:06:06 +0000
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;To: linux-mm
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Subject: Re: [PATCH] mm&#x2F;mmap.c: make brk() check RLIMIT_AS before page-aligning requested amount
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Message-Id: &amp;lt;334b96f7-b01e-483b-86d3-a801c459a96b () lucifer ! local&amp;gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;X-MARC-Message: https:&#x2F;&#x2F;marc.info&#x2F;?l=linux-mm&amp;amp;m=172405830317307
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Thanks for your patch (I think your first? :), I don&amp;#39;t think this is
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;correct however. The address space usage is not changing between these
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;calls, it&amp;#39;s staying exactly the same (in fact, your efforts to avoid going
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;over a page boundary ensure this).
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;All memory allocations in the kernel are performed at page granularity, as
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;this is the only way to actually allocate and map memory.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;As per the man page:
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    Lowering the soft limit for a resource below the process&amp;#39;s current
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    consumption of that resource will succeed (but will prevent the process
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;    from further increasing its consumption of the resource).
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;So the limit will not prevent usage of existing resource (i.e. the address
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;space usage).
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;It seems that we make an effort with RLIMIT_DATA to actually proactively
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;prevent usage beyond the limit, again as per the man page:
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;       RLIMIT_DATA
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              This is the maximum size of the process&amp;#39;s data segment
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              (initialized data, uninitialized data, and heap).  The limit
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              is specified in bytes, and is rounded down to the system page
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              size.  This limit affects calls to brk(2), sbrk(2), and
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              (since Linux 4.7) mmap(2), which fail with the error ENOMEM
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              upon encountering the soft limit of this resource.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Note &amp;#39;encountering&amp;#39; the soft limit of this resource. In the case of
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;RLIMIT_AS:
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;       RLIMIT_AS
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              ...
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              This limit affects calls to brk(2), mmap(2), and mremap(2),
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              which fail with the error ENOMEM upon exceeding this limit.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;              ...
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Note &amp;#39;exceeding&amp;#39; this limit.
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;acknowledgements&quot;&gt;Acknowledgements&lt;a class=&quot;zola-anchor&quot; href=&quot;#acknowledgements&quot; aria-label=&quot;Anchor link for: acknowledgements&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;thomasqm.com&quot;&gt;thomasqm&lt;&#x2F;a&gt; spotted that the &lt;code&gt;RLIMIT_DATA&lt;&#x2F;code&gt; check before page-alignment was not a &lt;code&gt;RLIMIT_AS&lt;&#x2F;code&gt; check.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Temporary Values, Borrowing, and Lifetimes</title>
        <published>2023-01-22T00:00:00+00:00</published>
        <updated>2023-01-22T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.vashishtha.in/temporary-lifetimes/"/>
        <id>https://blog.vashishtha.in/temporary-lifetimes/</id>
        
        <content type="html" xml:base="https://blog.vashishtha.in/temporary-lifetimes/">&lt;h1 id=&quot;problem&quot;&gt;Problem&lt;a class=&quot;zola-anchor&quot; href=&quot;#problem&quot; aria-label=&quot;Anchor link for: problem&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Prior to Rust &lt;a href=&quot;https:&#x2F;&#x2F;releases.rs&#x2F;docs&#x2F;1.61.0&#x2F;&quot; title=&quot;release notes&quot;&gt;v1.61.0&lt;&#x2F;a&gt;, the &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;stable&#x2F;std&#x2F;io&#x2F;struct.Stdin.html#method.lock&quot;&gt;&lt;code&gt;std::io::stdio::Stdin::lock&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; function &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;93965&#x2F;&quot; title=&quot;relevant Pull Request&quot;&gt;had a signature&lt;&#x2F;a&gt; that looked like this:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;lock&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;StdinLock&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&amp;#39;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;_&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lifetimes &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;reference&#x2F;lifetime-elision.html#lifetime-elision-in-functions&quot; title=&quot;Rust Reference - Lifetime Elision in Functions&quot;&gt;un-elided&lt;&#x2F;a&gt;, it looks like:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;lock&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier z-lifetime z-rust&quot;&gt;&amp;#39;a&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier z-lifetime z-rust&quot;&gt;&amp;#39;a&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;StdinLock&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier z-lifetime z-rust&quot;&gt;&amp;#39;a&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;which translates to the following:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;The returned &lt;code&gt;StdinLock&lt;&#x2F;code&gt; is valid for the lifetime &lt;code&gt;&#x27;a&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;The lifetime &lt;code&gt;&#x27;a&lt;&#x2F;code&gt; originates from a borrow of a &lt;code&gt;Stdin&lt;&#x2F;code&gt; struct.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;blockquote&gt;
&lt;p&gt;It also implies that the &lt;code&gt;StdinLock&lt;&#x2F;code&gt; must be dropped before mutably borrowing the &lt;code&gt;Stdin&lt;&#x2F;code&gt; struct, and that we can&#x27;t drop the &lt;code&gt;Stdin&lt;&#x2F;code&gt; struct before dropping the &lt;code&gt;StdinLock&lt;&#x2F;code&gt; struct.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;So what happens when we use &lt;code&gt;lock&lt;&#x2F;code&gt;?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-keyword z-other z-rust&quot;&gt;use&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;io&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; locked &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;io&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;stdin&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;lock&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;pub fn stdin() -&amp;gt; Stdin&lt;&#x2F;code&gt;, btw.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A wild compile error appears!&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;error[E0716]: temporary value dropped while borrowed
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; --&amp;gt; src&#x2F;main.rs:3:14
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;3 |     let locked = io::stdin().lock();
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|                  ^^^^^^^^^^^       - temporary value is freed at the end of this statement
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|                  |
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|                  creates a temporary which is freed while still in use
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;4 | }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	| - borrow might be used here, when `locked` is dropped and runs the destructor for type `StdinLock&amp;lt;&amp;#39;_&amp;gt;`
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	= note: consider using a `let` binding to create a longer lived value
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;But &lt;em&gt;where&lt;&#x2F;em&gt; did the borrow come from? Well, when calling a method with an &lt;code&gt;&amp;amp;self&lt;&#x2F;code&gt; parameter with an owned value, the Rust compiler can &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;reference&#x2F;expressions.html#implicit-borrows&quot; title=&quot;Rust Reference - Implicit Borrows&quot;&gt;implicitly borrow&lt;&#x2F;a&gt; the owned value to call the &lt;code&gt;&amp;amp;self&lt;&#x2F;code&gt; method.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h1 id=&quot;explanation&quot;&gt;Explanation&lt;a class=&quot;zola-anchor&quot; href=&quot;#explanation&quot; aria-label=&quot;Anchor link for: explanation&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;A borrow is &lt;em&gt;against&lt;&#x2F;em&gt; an owned value. That is, borrows can&#x27;t be conjured from thin air. &lt;small&gt;Borrows &lt;em&gt;aren&#x27;t&lt;&#x2F;em&gt; pointers. You can&#x27;t &lt;em&gt;hold&lt;&#x2F;em&gt; a value with a borrow, you need an owner backing it.&lt;&#x2F;small&gt;&lt;&#x2F;li&gt;
&lt;li&gt;A borrow can only last as long as the owned value. It can&#x27;t live after the owned value is dropped.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;reference&#x2F;expressions.html#temporaries&quot; title=&quot;Rust Reference - Temporaries&quot;&gt;Temporaries&lt;&#x2F;a&gt; are dropped at the end of a statement (&lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;reference&#x2F;destructors.html#temporary-lifetime-extension&quot; title=&quot;Temporary Lifetime Extension&quot;&gt;except when they&#x27;re not&lt;&#x2F;a&gt;), while values stored in &lt;code&gt;let&lt;&#x2F;code&gt;s drop at the end of a block.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;For more information on dropping behaviour, see &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;reference&#x2F;destructors.html#drop-scopes&quot;&gt;Drop Order&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;For a much more concise explanation of the problem, I defer to the original issue for changing &lt;code&gt;std::io::Stdin::lock&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;The explanation is that the lock behaves as if it borrows the original handle from stdin(), and the temporary value created for the call to the lock() method is dropped at the end of the statement, invalidating the borrow.&lt;&#x2F;p&gt;
&lt;p&gt;-- &lt;cite&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;issues&#x2F;86845#issue-936286530%3E&quot; title=&quot;tlyu&amp;#39;s Issue Comment&quot;&gt;tlyu&lt;&#x2F;a&gt;&lt;&#x2F;cite&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h1 id=&quot;reproducing-the-problem&quot;&gt;Reproducing the problem&lt;a class=&quot;zola-anchor&quot; href=&quot;#reproducing-the-problem&quot; aria-label=&quot;Anchor link for: reproducing-the-problem&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Why don&#x27;t you encounter the same problem when borrowing in other places?
Most reference parameters to functions don&#x27;t have their lifetimes tied to the output in the same way.
This compiles just fine:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;print_str&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;s&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;str&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-support z-macro z-rust&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder z-rust&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; s&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-support z-function z-rust&quot;&gt;print_str&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;from&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;abc&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;while the de-elided &lt;small&gt;(delided?)&lt;&#x2F;small&gt; signature of &lt;code&gt;as_str()&lt;&#x2F;code&gt; is &lt;code&gt;pub fn as_str(&amp;amp;self) -&amp;gt; &amp;amp;str&lt;&#x2F;code&gt;, which also returns a reference with the &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;reference&#x2F;lifetime-elision.html#lifetime-elision-in-functions&quot; title=&quot;Rust Reference - Lifetime Elision in Functions&quot;&gt;same&lt;&#x2F;a&gt; lifetime as the input..
However! If we add but a return argument to &lt;code&gt;print_str&lt;&#x2F;code&gt;...&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;print_str&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;s&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;str&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;str&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-support z-macro z-rust&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder z-rust&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; s&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	s
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-support z-function z-rust&quot;&gt;print_str&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;from&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;abc&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The output:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;abc
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;What. I totally thought I was going to prove my point there. What if I...&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;print_str&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;s&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;str&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;str&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-support z-macro z-rust&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder z-rust&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; s&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	s
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; s &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-rust&quot;&gt;print_str&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;from&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;abc&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-support z-macro z-rust&quot;&gt;dbg!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;s&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Aha!&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;error[E0716]: temporary value dropped while borrowed
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt; --&amp;gt; src&#x2F;main.rs:7:20
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;7 |     let s = print_str(String::from(&amp;quot;abc&amp;quot;).as_str());
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|                       ^^^^^^^^^^^^^^^^^^^          - temporary value is freed at the end of this statement
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|                       |
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|                       creates a temporary which is freed while still in use
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;8 |     dbg!(s);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|          - borrow later used here
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;help: consider using a `let` binding to create a longer lived value
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;7 ~     let binding = String::from(&amp;quot;abc&amp;quot;);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;8 ~  let s = print_str(binding.as_str());
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;	|
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Our borrowed value (reference) can only live as long as the value we borrow against, and in this case, that temporary is dropped at the end of the statement. Previously, the Rust compiler didn&#x27;t give us an error because we weren&#x27;t using the borrow later, and the lifetime of the borrow could be the same as the temporary.&lt;&#x2F;p&gt;
&lt;p&gt;But in this case, the reference that &lt;code&gt;print_str&lt;&#x2F;code&gt; returns has the same&lt;sup&gt;&lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;nomicon&#x2F;subtyping.html&quot; title=&quot;Rustonomicon - Subtyping and Variance&quot;&gt;ish&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; lifetime as the one that &lt;code&gt;as_str&lt;&#x2F;code&gt; returns, which is limited by the temporary &lt;code&gt;String&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Once you start learning about all the weird tricks the Rust compiler has in order to make &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;nomicon&#x2F;subtyping.html&quot; title=&quot;Rustonomicon - Subtyping and Variance&quot;&gt;lifetimes convenient&lt;&#x2F;a&gt;, you get uncomfortable calling two lifetimes &quot;equal&quot; or the &quot;same&quot;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;The solution is exactly what the compiler suggests: as soon as we put our owned value in a &lt;code&gt;let&lt;&#x2F;code&gt; statement, it will be dropped at the end of scope and we can freely borrow against it until then.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;retrospective&quot;&gt;Retrospective&lt;a class=&quot;zola-anchor&quot; href=&quot;#retrospective&quot; aria-label=&quot;Anchor link for: retrospective&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;So how did the Rust community change &lt;code&gt;Stdin::lock&lt;&#x2F;code&gt; so that users no longer faced this error? They changed the signature to &lt;code&gt;pub fn lock(&amp;amp;self) -&amp;gt; StdinLock&amp;lt;&#x27;static&amp;gt;&lt;&#x2F;code&gt;, which decouples the lifetime relationship, allowing the returned &lt;code&gt;StdinLock&lt;&#x2F;code&gt; to outlive the &lt;code&gt;&amp;amp;self&lt;&#x2F;code&gt; reference. &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;93965&#x2F;&quot; title=&quot;relevant Pull Request&quot;&gt;How they did that&lt;&#x2F;a&gt; is &lt;abbr title = &quot;I am too lazy or uncertain about my expertise.&quot;&gt;left to reader&lt;&#x2F;abbr&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;further-reading&quot;&gt;Further Reading&lt;a class=&quot;zola-anchor&quot; href=&quot;#further-reading&quot; aria-label=&quot;Anchor link for: further-reading&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Covariance_and_contravariance_(computer_science)&quot;&gt;Variance and Covariance&lt;&#x2F;a&gt;, and how it relates to &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;nomicon&#x2F;subtyping.html&quot; title=&quot;Rustonomicon - Subtyping and Variance&quot;&gt;Rust lifetimes&lt;&#x2F;a&gt; - they can shrink.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;pretzelhammer&#x2F;rust-blog&#x2F;blob&#x2F;master&#x2F;posts&#x2F;common-rust-lifetime-misconceptions.md&quot;&gt;Pretzelhammer&#x27;s article on Common Rust Lifetime Misconceptions&lt;&#x2F;a&gt; will &lt;em&gt;blow your mind&lt;&#x2F;em&gt; if you&#x27;ve only read the &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;&quot;&gt;Book&lt;&#x2F;a&gt; so far.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;a-rust-match-made-in-hell&quot;&gt;fasterthanlime&#x27;s &quot;A Rust match made in hell&quot;&lt;&#x2F;a&gt; explores a similar problem related to how match expression scrutinees can extend temporary lifetimes, and how that conflicts with locks.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;smallcultfollowing.com&#x2F;babysteps&#x2F;blog&#x2F;2023&#x2F;03&#x2F;15&#x2F;temporary-lifetimes&#x2F;#current-rules&quot;&gt;The section discussing current rules in Niko Matsaki&#x27;s similarly titled &quot;Temporary Lifetimes&quot;&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Beginner-Intermediate Rust Error Handling</title>
        <published>2022-06-05T00:00:00+00:00</published>
        <updated>2022-06-05T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.vashishtha.in/rust-error-handling/"/>
        <id>https://blog.vashishtha.in/rust-error-handling/</id>
        
        <content type="html" xml:base="https://blog.vashishtha.in/rust-error-handling/">&lt;blockquote&gt;
&lt;p&gt;This article assumes you&#x27;ve read most of the &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;&quot;&gt;The Rust Programming Language&lt;&#x2F;a&gt; book.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h1 id=&quot;pre-introduction&quot;&gt;Pre-Introduction&lt;a class=&quot;zola-anchor&quot; href=&quot;#pre-introduction&quot; aria-label=&quot;Anchor link for: pre-introduction&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;There are mainly two styles of error handling you&#x27;ll need using Rust, or for that matter, most languages:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Application level error handling, where you don&#x27;t care as much about handling errors than propagating them.&lt;&#x2F;li&gt;
&lt;li&gt;Library level error handling, where it&#x27;s imperative that you have neat errors that you can return.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The rest of the article is written with the second perspective. What follows is not definitive practice - I&#x27;d actually instead recommend &lt;a href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;anyhow&quot;&gt;anyhow&lt;&#x2F;a&gt; for the first need, and &lt;a href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;thiserror&quot;&gt;thiserror&lt;&#x2F;a&gt; for a less-opinionated library for the second need, along with &lt;a href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;snafu&quot;&gt;snafu&lt;&#x2F;a&gt; for a more opinionated version.&lt;&#x2F;p&gt;
&lt;p&gt;What follows is more of an evolution of practices than anything else.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;a class=&quot;zola-anchor&quot; href=&quot;#introduction&quot; aria-label=&quot;Anchor link for: introduction&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Let&#x27;s take the example of a command-line app we&#x27;re developing. Any good command-line app needs a configuration file to toggle behavior. Let&#x27;s write some code for that.&lt;&#x2F;p&gt;
&lt;p&gt;lib.rs&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-module z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-module z-rust&quot;&gt;mod&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-name z-module z-rust&quot;&gt;config&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;config.rs&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-struct z-rust&quot;&gt;struct&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-entity z-name z-struct z-rust&quot;&gt;Config&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-other z-member z-rust&quot;&gt;name&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-type z-rust&quot;&gt;:&lt;&#x2F;span&gt; String,
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;To write a function that returns &lt;code&gt;Config&lt;&#x2F;code&gt;, we&#x27;ll have to:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open the file that&#x27;s passed to us (take a &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;path&#x2F;struct.Path.html&quot;&gt;&lt;code&gt;std::fs::Path&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;) and read it (with the &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;fs&#x2F;struct.File.html&quot;&gt;&lt;code&gt;std::fs::File&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; struct).&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Parse the file as JSON and deserialize into Config. (We&#x27;ll use the excellent &lt;a href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;serde&quot;&gt;&lt;code&gt;serde&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;serde_json&quot;&gt;&lt;code&gt;serde_json&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; libraries)&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;blockquote&gt;
&lt;p&gt;To use &lt;code&gt;serde&lt;&#x2F;code&gt; and &lt;code&gt;serde_json&lt;&#x2F;code&gt;, we&#x27;ll add them to our dependencies.&lt;&#x2F;p&gt;
&lt;p&gt;cargo.toml&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;toml&quot; class=&quot;language-toml z-code&quot;&gt;&lt;code class=&quot;language-toml&quot; data-lang=&quot;toml&quot;&gt;&lt;span class=&quot;z-source z-toml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-table z-begin z-toml&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-tag z-table z-toml&quot;&gt;&lt;span class=&quot;z-entity z-name z-table z-toml&quot;&gt;dependencies&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-table z-end z-toml&quot;&gt;]&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-toml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-key z-toml&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-toml&quot;&gt;serde&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-key-value z-toml&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-inline-table z-begin z-toml&quot;&gt;{&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-tag z-key z-toml&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-toml&quot;&gt;version&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-key-value z-toml&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-basic z-toml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-toml&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;1.0.137&lt;span class=&quot;z-punctuation z-definition z-string z-end z-toml&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-inline-table z-toml&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-tag z-key z-toml&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-toml&quot;&gt;features&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-key-value z-toml&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-array z-begin z-toml&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-basic z-toml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-toml&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;derive&lt;span class=&quot;z-punctuation z-definition z-string z-end z-toml&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-array z-end z-toml&quot;&gt;]&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-inline-table z-end z-toml&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-toml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-key z-toml&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-toml&quot;&gt;serde_json&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-key-value z-toml&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-basic z-toml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-toml&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;1.0.81&lt;span class=&quot;z-punctuation z-definition z-string z-end z-toml&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;&#x2F;blockquote&gt;
&lt;h3 id=&quot;read-file&quot;&gt;read_file&lt;a class=&quot;zola-anchor&quot; href=&quot;#read-file&quot; aria-label=&quot;Anchor link for: read-file&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;We first write a &lt;code&gt;read_file&lt;&#x2F;code&gt; function:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;read_file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;path&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;Path&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;Result&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;Vec&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u8&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;, &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;io&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;mut&lt;&#x2F;span&gt; f &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;File&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;open&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-bitwise z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;path&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;?&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;mut&lt;&#x2F;span&gt; buf &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Vec&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;new&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    f&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;read_to_end&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-bitwise z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;mut&lt;&#x2F;span&gt; buf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;?&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Ok&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;buf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;It uses the &lt;code&gt;?&lt;&#x2F;code&gt; operator to &quot;early-return&quot; in the case of an error.
In this case, we use &lt;code&gt;io::Error&lt;&#x2F;code&gt; in the return type since that&#x27;s what both the functions we call use.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;config-file&quot;&gt;config_file&lt;a class=&quot;zola-anchor&quot; href=&quot;#config-file&quot; aria-label=&quot;Anchor link for: config-file&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;We then write our &lt;code&gt;config_file&lt;&#x2F;code&gt; function, which calls &lt;code&gt;read_file&lt;&#x2F;code&gt; to get a buffer it can then deserialize with &lt;code&gt;serde_json&lt;&#x2F;code&gt; into &lt;code&gt;Config&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Before that, we&#x27;ll need to derive Deserialize for &lt;code&gt;Config&lt;&#x2F;code&gt; in order to use &lt;code&gt;serde_json&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-annotation z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-annotation z-rust&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-annotation z-rust&quot;&gt;derive&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;Deserialize&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-struct z-rust&quot;&gt;struct&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-entity z-name z-struct z-rust&quot;&gt;Config&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;  &lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-other z-member z-rust&quot;&gt;name&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-type z-rust&quot;&gt;:&lt;&#x2F;span&gt; String    
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;We&#x27;ll define a custom error type which is an enum of both of our possible errors.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-annotation z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-annotation z-rust&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-annotation z-rust&quot;&gt;derive&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;Debug&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-enum z-rust&quot;&gt;enum&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-name z-enum z-rust&quot;&gt;ConfigError&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    FileError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;io&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    DeserializeError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;serde_json&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;This enum pattern has some notable limitations, and in extreme cases can form an anti-pattern.
We&#x27;ll discuss that later.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;We use this as the &lt;code&gt;Err&lt;&#x2F;code&gt; type in our return value.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;mark&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;config_file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;path&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;Path&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;Result&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;Config, ConfigError&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;mark&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; buf &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-rust&quot;&gt;read_file&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;path&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;?&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; conf &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;serde_json&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;from_slice&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-bitwise z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;buf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;?&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-comment z-line z-double-slash z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; deserializes bytes into Config
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Ok&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;conf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;the-from-trait-for-errors&quot;&gt;The &lt;code&gt;From&lt;&#x2F;code&gt; trait for Errors&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-from-trait-for-errors&quot; aria-label=&quot;Anchor link for: the-from-trait-for-errors&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The above snippet doesn&#x27;t quite work: &lt;code&gt;read_file&lt;&#x2F;code&gt; returns a Result with an error type of &lt;code&gt;io::Error&lt;&#x2F;code&gt;, and &lt;code&gt;serde_json::from_slice&lt;&#x2F;code&gt; returns &lt;code&gt;serde_json::Error&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;We can&#x27;t use the &lt;code&gt;?&lt;&#x2F;code&gt; operator here to return an Error since the function returns a Result with the error type &lt;code&gt;ConfigError&lt;&#x2F;code&gt;.
One way we can make this work is using the &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;convert&#x2F;trait.From.html&quot;&gt;&lt;code&gt;From&amp;lt;T&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; trait for our error types.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-annotation z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-annotation z-rust&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-annotation z-rust&quot;&gt;derive&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;Debug&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-enum z-rust&quot;&gt;enum&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-name z-enum z-rust&quot;&gt;ConfigError&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    FileError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;io&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    DeserializeError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;serde_json&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;5&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-impl z-rust&quot;&gt;impl&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;From&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;serde_json&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-rust&quot;&gt;for&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt; &lt;span class=&quot;z-entity z-name z-impl z-rust&quot;&gt;ConfigError&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;from&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;serde_json&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;Self&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;Self&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;DeserializeError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-impl z-rust&quot;&gt;impl&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;From&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;io&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-rust&quot;&gt;for&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt; &lt;span class=&quot;z-entity z-name z-impl z-rust&quot;&gt;ConfigError&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;from&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;io&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;Self&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;Self&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;FileError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Great!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;encoding-relevant-information-in-configerror&quot;&gt;Encoding Relevant Information in ConfigError&lt;a class=&quot;zola-anchor&quot; href=&quot;#encoding-relevant-information-in-configerror&quot; aria-label=&quot;Anchor link for: encoding-relevant-information-in-configerror&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Next, let&#x27;s try using our interface.&lt;&#x2F;p&gt;
&lt;p&gt;main.rs&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-keyword z-other z-rust&quot;&gt;use&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;error_demo&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;config&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;config_file&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; conf &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-rust&quot;&gt;config_file&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;config.json&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;unwrap&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;	&lt;span class=&quot;z-support z-macro z-rust&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder z-rust&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; conf&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;name&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This errors. No surprise, because I haven&#x27;t really made a &lt;code&gt;config.json&lt;&#x2F;code&gt; file yet.&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;thread &amp;#39;main&amp;#39; panicked at &amp;#39;called `Result::unwrap()` on an `Err` value: FileError(Os { code: 2, kind: NotFound, message: &amp;quot;No such file or directory&amp;quot; })&amp;#39;, src&#x2F;main.rs:4:43
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;stack backtrace:
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;   0: rust_begin_unwind
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;             at &#x2F;rustc&#x2F;7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c&#x2F;library&#x2F;std&#x2F;src&#x2F;panicking.rs:584:5
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;   1: core::panicking::panic_fmt
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;             at &#x2F;rustc&#x2F;7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c&#x2F;library&#x2F;core&#x2F;src&#x2F;panicking.rs:143:14
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;   2: core::result::unwrap_failed
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;             at &#x2F;rustc&#x2F;7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c&#x2F;library&#x2F;core&#x2F;src&#x2F;result.rs:1749:5
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;   3: core::result::Result&amp;lt;T,E&amp;gt;::unwrap
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;             at &#x2F;rustc&#x2F;7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c&#x2F;library&#x2F;core&#x2F;src&#x2F;result.rs:1065:23
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;   4: error_demo::main
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;             at .&#x2F;src&#x2F;main.rs:4:13
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;   5: core::ops::function::FnOnce::call_once
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;             at &#x2F;rustc&#x2F;7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c&#x2F;library&#x2F;core&#x2F;src&#x2F;ops&#x2F;function.rs:227:5
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;The terminal process &amp;quot;cargo &amp;#39;run&amp;#39;, &amp;#39;--package&amp;#39;, &amp;#39;error-demo&amp;#39;, &amp;#39;--bin&amp;#39;, &amp;#39;error-demo&amp;#39;&amp;quot; terminated with exit code: 101.
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Note that the backtrace requires the &lt;code&gt;RUST_BACKTRACE=1&lt;&#x2F;code&gt; environment variable to be set.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This is unfortunately a rather obscure error.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;While it gives us the line the panic originated on (&lt;code&gt;src&#x2F;main.rs:4:43&lt;&#x2F;code&gt;), it cannot tell the source of the &lt;em&gt;error&lt;&#x2F;em&gt; itself.&lt;&#x2F;li&gt;
&lt;li&gt;It informs us that &quot;a File was NotFound&quot;, but unfortunately we can&#x27;t see &lt;em&gt;which&lt;&#x2F;em&gt; file we failed to open.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;We could resolve the second by redefining our &lt;code&gt;ConfigError&lt;&#x2F;code&gt; enum to instead be a struct and contain the error type along with the path.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-annotation z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-annotation z-rust&quot;&gt;#&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-annotation z-rust&quot;&gt;derive&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;Debug&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-annotation z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-enum z-rust&quot;&gt;enum&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-name z-enum z-rust&quot;&gt;ConfigErrorType&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    FileError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;io&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    DeserializeError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;serde_json&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-enum z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-struct z-rust&quot;&gt;struct&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-entity z-name z-struct z-rust&quot;&gt;ConfigError&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-variable z-other z-member z-rust&quot;&gt;path&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-type z-rust&quot;&gt;:&lt;&#x2F;span&gt; PathBuf
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    err&lt;span class=&quot;z-punctuation z-separator z-type z-rust&quot;&gt;:&lt;&#x2F;span&gt; ConfigErrorType
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;While we could have a more efficient type for path (&lt;code&gt;&amp;amp;&#x27;a Path&lt;&#x2F;code&gt;) in our error type, we skip that for simplicity&#x27;s sake.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Our nice &lt;code&gt;?&lt;&#x2F;code&gt; work breaks down here. Instead,&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;read_file&lt;&#x2F;code&gt; and &lt;code&gt;serde_json::from_slice&lt;&#x2F;code&gt; returns incompatible error types.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;we first coerce them to the same type using &lt;code&gt;.map_err(|e| e.into())&lt;&#x2F;code&gt; - this uses the &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;convert&#x2F;trait.Into.html&quot;&gt;&lt;code&gt;Into&amp;lt;T&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; trait, which is
automatically implemented for types that implement &lt;code&gt;From&amp;lt;T&amp;gt;&lt;&#x2F;code&gt; in the opposite direction.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;From&amp;lt;std::io::Error&amp;gt;&lt;&#x2F;code&gt; is implemented for &lt;code&gt;ConfigErrorType&lt;&#x2F;code&gt; implies that &lt;code&gt;Into&amp;lt;ConfigErrorType&amp;gt;&lt;&#x2F;code&gt; is implemented for &lt;code&gt;std::io::Error&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;next we use a closure we&#x27;ve build earlier which has &quot;closed over&quot; (or captured) the path to convert into a &lt;code&gt;PathBuf&lt;&#x2F;code&gt; and construct a &lt;code&gt;ConfigError&lt;&#x2F;code&gt; from a the passed &lt;code&gt;ConfigErrorType&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;blockquote&gt;
&lt;p&gt;The &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;result&#x2F;enum.Result.html#method.map_err&quot;&gt;&lt;code&gt;map_err&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; methods accepts anything that implements the &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;ops&#x2F;trait.FnOnce.html&quot;&gt;&lt;code&gt;FnOnce&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; trait, which includes closures.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;config_file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;path&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;Path&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;Result&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;Config, ConfigError&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;construct_config_error&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-closure z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-closure z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;err&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-closure z-rust&quot;&gt;ConfigError &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;path&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; path&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;to_path_buf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; err&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; buf &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-rust&quot;&gt;read_file&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;path&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;map_err&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-closure z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-closure z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-closure z-rust&quot;&gt;e&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;into&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;map_err&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;construct_config_error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;?&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; conf &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;serde_json&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;from_slice&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-bitwise z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;buf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;map_err&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-closure z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-closure z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-closure z-rust&quot;&gt;e&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;into&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;map_err&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;construct_config_error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;?&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Ok&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;conf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;If you&#x27;re feeling particularly clever, you could even write &lt;code&gt;Into::into&lt;&#x2F;code&gt; (qualified: &lt;code&gt;std::convert::Into::into&lt;&#x2F;code&gt;) for the first &lt;code&gt;map_err&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Rerunning &lt;code&gt;get_context&lt;&#x2F;code&gt;, we get a somewhat better error message.&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;thread &amp;#39;main&amp;#39; panicked at &amp;#39;called `Result::unwrap()` on an `Err` value: FileError(FileError { path: &amp;quot;config.json&amp;quot;, err: Os { code: 2, kind: NotFound, message: &amp;quot;No such file or directory&amp;quot; } })&amp;#39;, src&#x2F;main.rs:4:51
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;even-nicer-errors-with-std-fmt&quot;&gt;&lt;em&gt;Even&lt;&#x2F;em&gt; nicer errors with &lt;code&gt;std::fmt&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#even-nicer-errors-with-std-fmt&quot; aria-label=&quot;Anchor link for: even-nicer-errors-with-std-fmt&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Did you know? There&#x27;s a trait responsible for printing out the struct representation in the above error, and that&#x27;s &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;fmt&#x2F;trait.Debug.html&quot;&gt;&lt;code&gt;std::fmt::Debug&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;. That&#x27;s what &lt;code&gt;unwrap&lt;&#x2F;code&gt; calls. If we permit ourselves to a little dive in the guts of &lt;code&gt;std::result&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-impl z-rust&quot;&gt;impl&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;T, E&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt; &lt;span class=&quot;z-entity z-name z-impl z-rust&quot;&gt;Result&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;T, E&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-comment z-line z-double-slash z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;--snip--
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;unwrap&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; T
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-keyword z-other z-rust&quot;&gt;where&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;        E&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;fmt&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Debug,
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;match&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Ok&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;t&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;=&amp;gt;&lt;&#x2F;span&gt; t&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Err&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;=&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-rust&quot;&gt;unwrap_failed&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;called `Result::unwrap()` on an `Err` value&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-bitwise z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-comment z-line z-double-slash z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;--snip--
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;unwrap_failed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;msg&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;str&lt;&#x2F;span&gt;, &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;error&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;dyn &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;fmt&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Debug&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-rust&quot;&gt;!&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-support z-macro z-rust&quot;&gt;panic!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;{}: {:?}&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; msg&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; error&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-comment z-line z-double-slash z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;--snip--
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &lt;code&gt;panic&lt;&#x2F;code&gt; function uses &lt;code&gt;std::fmt::Debug&lt;&#x2F;code&gt; to format the &lt;code&gt;error&lt;&#x2F;code&gt; value with the &lt;code&gt;{:?}&lt;&#x2F;code&gt; &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;fmt&#x2F;index.html&quot;&gt;format arg&lt;&#x2F;a&gt;, while it &lt;em&gt;calls another trait&lt;&#x2F;em&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;fmt&#x2F;trait.Display.html&quot;&gt;&lt;code&gt;std::fmt::Display&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; to format the &lt;code&gt;msg&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;While &lt;code&gt;Debug&lt;&#x2F;code&gt; intends to provide a programmer-friendly debug representation, &lt;code&gt;Display&lt;&#x2F;code&gt; is meant for an end user&#x27;s eyes and thus usually nicer to look at.&lt;&#x2F;p&gt;
&lt;p&gt;A good comparison between the two is their handling for &lt;code&gt;std::string::String&lt;&#x2F;code&gt;s:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; s &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-type z-rust&quot;&gt;String&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;from&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;A string with weird&lt;span class=&quot;z-constant z-character z-escape z-rust&quot;&gt;\t&lt;&#x2F;span&gt;spacing and &lt;span class=&quot;z-constant z-character z-escape z-rust&quot;&gt;\n&lt;&#x2F;span&gt;newlines&lt;span class=&quot;z-constant z-character z-escape z-rust&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-support z-macro z-rust&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder z-rust&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; s&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-support z-macro z-rust&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other z-placeholder z-rust&quot;&gt;{:?}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; s&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &lt;code&gt;Display&lt;&#x2F;code&gt; implementation prints:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;A string with weird		spacing and 
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;newlines
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &lt;code&gt;Debug&lt;&#x2F;code&gt; implementation prints:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;quot;A string with weird\t\tspacing and \nnewlines\n&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;implementing-debug-for-our-error-type&quot;&gt;Implementing Debug for our Error type&lt;a class=&quot;zola-anchor&quot; href=&quot;#implementing-debug-for-our-error-type&quot; aria-label=&quot;Anchor link for: implementing-debug-for-our-error-type&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;You might have seen that we&#x27;ve just plonked a &lt;code&gt;#[derive(Debug)]&lt;&#x2F;code&gt; on all of our enums and structs so far, but we can also implement it ourselves.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Deriving &lt;code&gt;Debug&lt;&#x2F;code&gt; on a struct or enum requires all the elements inside to also implement &lt;code&gt;Debug&lt;&#x2F;code&gt;. Practically all the standard library types implement &lt;code&gt;Debug&lt;&#x2F;code&gt;, and implementing it on your own is usually as simple as &lt;code&gt;#[derive(Debug)]&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Types that implement &lt;code&gt;Debug&lt;&#x2F;code&gt; don&#x27;t necessarily implement &lt;code&gt;Display&lt;&#x2F;code&gt;, however. &lt;code&gt;std::path::PathBuf&lt;&#x2F;code&gt; is a good example - since it can represent arbitrary byte sequences, it must necessarily represent them in a debuggable form, or risk messing up a terminal with binary data.&lt;&#x2F;p&gt;
&lt;p&gt;Before messing with implementing &lt;code&gt;Debug&lt;&#x2F;code&gt;, let&#x27;s first implement &lt;code&gt;Display&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-impl z-rust&quot;&gt;impl&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;Display &lt;span class=&quot;z-keyword z-other z-rust&quot;&gt;for&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt; &lt;span class=&quot;z-entity z-name z-impl z-rust&quot;&gt;ConfigError&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;fmt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;self&lt;&#x2F;span&gt;, &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;f&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;mut&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;fmt&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;Formatter&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&amp;#39;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;_&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;fmt&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Result&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;match&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-bitwise z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;err &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;ConfigErrorType&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;FileError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;=&amp;gt;&lt;&#x2F;span&gt; f&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;write_fmt&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-macro z-rust&quot;&gt;format_args!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;could not open file {:?} due to error {:?}&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;path&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; e&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;ConfigErrorType&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;DeserializeError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;=&amp;gt;&lt;&#x2F;span&gt; f&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;write_fmt&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-macro z-rust&quot;&gt;format_args!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;could not deserialize file {:?} due to error {:?}&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;path&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; e&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Next, we can use the above implementation for implementing &lt;code&gt;Debug&lt;&#x2F;code&gt; as well.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-comment z-line z-double-slash z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt; Forward to display implementation
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-impl z-rust&quot;&gt;impl&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;fmt&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Debug &lt;span class=&quot;z-keyword z-other z-rust&quot;&gt;for&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt; &lt;span class=&quot;z-entity z-name z-impl z-rust&quot;&gt;ConfigError&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;fmt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;self&lt;&#x2F;span&gt;, &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;f&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;mut&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;fmt&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;Formatter&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&amp;#39;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;_&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;fmt&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Result&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-keyword z-operator z-comparison z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;ConfigError &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;as&lt;&#x2F;span&gt; Display&lt;span class=&quot;z-keyword z-operator z-comparison z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;fmt&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; f&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I like doing it this way for two reasons:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;It makes removing the custom &lt;code&gt;Debug&lt;&#x2F;code&gt; impl much cleaner - delete the above code, then plonk &lt;code&gt;#[derive(Debug)]&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;Implementing it on &lt;code&gt;Display&lt;&#x2F;code&gt; makes it clear that the error is meant to be user-facing, and it just so happens that
the user-facing implementation exposes enough detail to allow for debugging.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Now, we get a nicer error message.&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;thread &amp;#39;main&amp;#39; panicked at &amp;#39;called `Result::unwrap()` on an `Err` value: Could not open file &amp;quot;config.json&amp;quot; due to error Os { code: 2, kind: NotFound, message: &amp;quot;No such file or directory&amp;quot; }&amp;#39;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;turning-on-easy-mode-with-the-error-trait&quot;&gt;Turning on Easy Mode with the &lt;code&gt;Error&lt;&#x2F;code&gt; trait&lt;a class=&quot;zola-anchor&quot; href=&quot;#turning-on-easy-mode-with-the-error-trait&quot; aria-label=&quot;Anchor link for: turning-on-easy-mode-with-the-error-trait&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;The standard library actually has a &lt;code&gt;std::error::Error&lt;&#x2F;code&gt; trait. It requires that the type implement &lt;code&gt;Display&lt;&#x2F;code&gt; and &lt;code&gt;Debug&lt;&#x2F;code&gt; before attempting to implement &lt;code&gt;Error&lt;&#x2F;code&gt;.
For a lot of errors, this could possibly be enough.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rs&quot; class=&quot;language-rs z-code&quot;&gt;&lt;code class=&quot;language-rs&quot; data-lang=&quot;rs&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-impl z-rust&quot;&gt;impl&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;error&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error &lt;span class=&quot;z-keyword z-other z-rust&quot;&gt;for&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt; &lt;span class=&quot;z-entity z-name z-impl z-rust&quot;&gt;ConfigError&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;source&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;Option&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;dyn &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;error&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error + &lt;span class=&quot;z-storage z-modifier z-lifetime z-rust&quot;&gt;&amp;#39;static&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; err&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-bitwise z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;dyn &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;error&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error &lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;+&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-modifier z-lifetime z-rust&quot;&gt;&amp;#39;static&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;match&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-bitwise z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;err &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;ConfigErrorType&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;FileError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;f&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;=&amp;gt;&lt;&#x2F;span&gt; f&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;ConfigErrorType&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;DeserializeError&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;d&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;=&amp;gt;&lt;&#x2F;span&gt; d
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Some&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;err&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Both the &lt;a href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;snafu&quot;&gt;&lt;code&gt;snafu&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;thiserror&quot;&gt;&lt;code&gt;thiserror&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; crates give you some nice macros to derive the &lt;code&gt;Error&lt;&#x2F;code&gt; trait for you.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;And then, a lot of error stuff becomes painless if you start boxing &#x27;em up, since return propagation is as simple as a &lt;code&gt;?&lt;&#x2F;code&gt; if your functions all return the same type. In exchange, for inspecting errors you have to downcast them, like so:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rs&quot; class=&quot;language-rs z-code&quot;&gt;&lt;code class=&quot;language-rs&quot; data-lang=&quot;rs&quot;&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-type z-rust&quot;&gt;type&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-name z-type z-rust&quot;&gt;Result&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-comparison z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;T&lt;span class=&quot;z-keyword z-operator z-comparison z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;result&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Result&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;T, &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;Box&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;dyn Error&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;read_file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;path&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;Path&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;Result&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;File&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Ok&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;File&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;open&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;path&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;?&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;call_read_file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; err &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-function z-rust&quot;&gt;read_file&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;path-that-doesnt-exist&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;as_ref&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Err&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;e&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; err &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; io_err&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;Box&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;std&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;io&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;Error&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; e&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;downcast&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;unwrap&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-macro z-rust&quot;&gt;matches!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;io_err&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;kind&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-path z-rust&quot;&gt;ErrorKind&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;NotFound&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-support z-macro z-rust&quot;&gt;eprintln!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;File not found!&lt;span class=&quot;z-punctuation z-definition z-string z-end z-rust&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;Ok(File::open(path)?)&lt;&#x2F;code&gt; looks &lt;em&gt;super&lt;&#x2F;em&gt; funky. It&#x27;s equivalent to &lt;code&gt;File::open(path).map_err(|e| e.into())&lt;&#x2F;code&gt;, or &lt;code&gt;File::open(path).map_err(Into::into)&lt;&#x2F;code&gt; if you&#x27;re feeling fancy. (It&#x27;s the same because the &lt;code&gt;?&lt;&#x2F;code&gt; operator tries to convert the Error type of the operand into the return Error type of type of the function. In this case, since any error that implements &lt;code&gt;Error&lt;&#x2F;code&gt; can be converted to &lt;code&gt;Box&amp;lt;dyn Error&amp;gt;&lt;&#x2F;code&gt; through the &lt;code&gt;From&lt;&#x2F;code&gt;&#x2F;&lt;code&gt;Into&lt;&#x2F;code&gt; traits, we&#x27;re good to go.)&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;matches!&lt;&#x2F;code&gt; macro returns a boolean; true if the given expression matches any of the given patterns. (uses the &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch18-02-refutability.html&quot;&gt;refutable pattern syntax&lt;&#x2F;a&gt;)&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h1 id=&quot;common-error-patterns&quot;&gt;Common Error Patterns&lt;a class=&quot;zola-anchor&quot; href=&quot;#common-error-patterns&quot; aria-label=&quot;Anchor link for: common-error-patterns&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;So far, we&#x27;d looked at designing our error as first an enum containing underlying error types, and then a struct with some context and an enum containing underlying error types.&lt;&#x2F;p&gt;
&lt;p&gt;While all errors are the same things in essence, there is a variety of methods in expressing them.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;boxing-the-error&quot;&gt;Boxing the error&lt;a class=&quot;zola-anchor&quot; href=&quot;#boxing-the-error&quot; aria-label=&quot;Anchor link for: boxing-the-error&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;One common method would be minimizing error size by &lt;code&gt;Box&lt;&#x2F;code&gt;ing it.&lt;&#x2F;p&gt;
&lt;p&gt;To quote &lt;code&gt;serde_json&lt;&#x2F;code&gt; v1.0.81,&lt;&#x2F;p&gt;
&lt;p&gt;src&#x2F;error.rs&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-comment z-line z-documentation z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&#x2F;&lt;&#x2F;span&gt; This type represents all possible errors that can occur when serializing or
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-comment z-line z-documentation z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&#x2F;&lt;&#x2F;span&gt; deserializing JSON data.
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-struct z-rust&quot;&gt;struct&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-entity z-name z-struct z-rust&quot;&gt;Error&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-comment z-line z-documentation z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&#x2F;&lt;&#x2F;span&gt; This `Box` allows us to keep the size of `Error` as small as possible. A
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-comment z-line z-documentation z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&#x2F;&lt;&#x2F;span&gt; larger `Error` type was substantially slower due to all the functions
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-comment z-line z-documentation z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-rust&quot;&gt;&#x2F;&#x2F;&#x2F;&lt;&#x2F;span&gt; that pass around `Result&amp;lt;T, Error&amp;gt;`.
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;21&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-variable z-other z-member z-rust&quot;&gt;err&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-type z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-support z-type z-rust&quot;&gt;Box&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;ErrorImpl&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;,
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;22&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;this-section-no-longer-exists&quot;&gt;This section no longer exists&lt;a class=&quot;zola-anchor&quot; href=&quot;#this-section-no-longer-exists&quot; aria-label=&quot;Anchor link for: this-section-no-longer-exists&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;There used to be a section here, but then I found matklad (Aleksey Kladov)&#x27;s &lt;em&gt;excellent&lt;&#x2F;em&gt; article &lt;a href=&quot;https:&#x2F;&#x2F;matklad.github.io&#x2F;2020&#x2F;10&#x2F;15&#x2F;study-of-std-io-error.html&quot;&gt;&quot;Study of std::io::Error&quot;&lt;&#x2F;a&gt;. Since I doubt if I could write it better, I&#x27;m linking to it instead.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;further-reading&quot;&gt;Further Reading&lt;a class=&quot;zola-anchor&quot; href=&quot;#further-reading&quot; aria-label=&quot;Anchor link for: further-reading&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;stable&#x2F;std&#x2F;result&#x2F;index.html&quot;&gt;&lt;code&gt;std::result::Result&lt;&#x2F;code&gt; documentation&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;stable&#x2F;std&#x2F;error&#x2F;trait.Error.html&quot;&gt;&lt;code&gt;std::error::Error&lt;&#x2F;code&gt; documentation&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I&#x27;ve referenced a few error-handling libraries at the start of the article - if you&#x27;d be interested in hearing more about a comparison between them, do let me know!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>&quot;It works on my machine&quot; - The Motivation for Containers</title>
        <published>2022-05-14T00:00:00+00:00</published>
        <updated>2022-05-14T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.vashishtha.in/why-docker/"/>
        <id>https://blog.vashishtha.in/why-docker/</id>
        
        <content type="html" xml:base="https://blog.vashishtha.in/why-docker/">&lt;h2 id=&quot;it-works-on-my-machine&quot;&gt;It works on &lt;em&gt;my&lt;&#x2F;em&gt; machine.&lt;a class=&quot;zola-anchor&quot; href=&quot;#it-works-on-my-machine&quot; aria-label=&quot;Anchor link for: it-works-on-my-machine&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Have you ever heard someone say, &quot;It works on &lt;em&gt;my&lt;&#x2F;em&gt; computer&quot; in response to a complaint about software not working?
It&#x27;s no surprise. Software is inherently complex, with myriad dependencies that are often updated or out-of-date.
Wouldn&#x27;t it be a joyous thing to develop stuff on your computer, and be secure in the knowledge that you can deploy it to servers
without any &lt;del&gt;gruesome&lt;&#x2F;del&gt; accidents?&lt;&#x2F;p&gt;
&lt;p&gt;Let&#x27;s start with our original computer, then try to build up a mechanism to ensure that it works on other computers as well.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;finite-state-machines&quot;&gt;Finite-State Machines&lt;a class=&quot;zola-anchor&quot; href=&quot;#finite-state-machines&quot; aria-label=&quot;Anchor link for: finite-state-machines&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;You can imagine your computer as a &lt;em&gt;finite-state machine&lt;&#x2F;em&gt; - it is completely predictable, &lt;em&gt;if&lt;&#x2F;em&gt; it starts from the same state, and gets the same inputs every time.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;A &lt;strong&gt;finite-state machine (FSM)&lt;&#x2F;strong&gt; or &lt;strong&gt;finite-state automaton&lt;&#x2F;strong&gt; (&lt;strong&gt;FSA&lt;&#x2F;strong&gt;, plural: &lt;em&gt;automata&lt;&#x2F;em&gt;), &lt;strong&gt;finite automaton&lt;&#x2F;strong&gt;, or simply a &lt;strong&gt;state machine&lt;&#x2F;strong&gt;, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number of states at any given time. The FSM can change from one state to another in response to some inputs; the change from one state to another is called a &lt;em&gt;transition&lt;&#x2F;em&gt;.
-- &lt;cite&gt;&lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Finite-state_machine&quot;&gt;Cribbed from Wikipedia&lt;&#x2F;a&gt;&lt;&#x2F;cite&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;In the context of strict reproducibility, inputs include everything from the time to the filesystem. Filesystems are nothing but global mutable stores. The time is never the same twice. Tough-to-reproduce bugs are often caused by race conditions (changes in the timing of threads causing unpredictable behaviour) and are notoriously difficult to replicate and disappear when you try to debug them (read: &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Heisenbug&quot;&gt;Heisenbugs&lt;&#x2F;a&gt;). Replicating &lt;em&gt;all of that&lt;&#x2F;em&gt; is a hassle, and likely unnecessary if we just want to get a program to work on a computer.&lt;&#x2F;p&gt;
&lt;p&gt;For the purpose of &quot;trying to get software running on another computer&quot;, we can relax our constraints a lot to just wanting the program to run.
The bare minimum required to do that would be to have the same environment - libraries, filesystem, operating system, etc., since programs cannot (usually) function without those pieces.&lt;&#x2F;p&gt;
&lt;p&gt;Before we start working on that, let&#x27;s take a moment to appreciate the number of ways the environment  &lt;em&gt;can go wrong.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;number-of-states&quot;&gt;Number of States&lt;a class=&quot;zola-anchor&quot; href=&quot;#number-of-states&quot; aria-label=&quot;Anchor link for: number-of-states&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;How many states does a disk have? Each bit has 2 states (1 or 0), a byte then has $2^8 = 256$ states. A modern hard disk can easily have a terabyte of memory.&lt;&#x2F;p&gt;
&lt;p&gt;$$
1 \text{ kilobyte} = 10^3 \text{ bytes}
$$
$$
1 \text{ megabyte} = 10^6 \text{ bytes}
$$
$$
1 \text{ gigabyte} = 10^9 \text{ bytes}
$$
$$
1 \text{ terabyte} = 10^{12} \text{ bytes}
$$&lt;&#x2F;p&gt;
&lt;p&gt;If a byte has $256$ states, and a terabyte has $10^{12}$ bytes, then the number of states in a terabyte is &lt;em&gt;not&lt;&#x2F;em&gt; $256 * 10^{12}$, but &lt;big&gt;$256^{10^{12}}$&lt;&#x2F;big&gt;, a &lt;em&gt;humongous&lt;&#x2F;em&gt; number.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#1&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Even the variance of a single byte between two drives can mess stuff up; even replicating the environment can prove to be difficult.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Of course, this is somewhat irrelevant when your states are tightly controlled:
installing the operating system on a blank drive is going to result in the same state no matter what.
However, I find this perspective valuable when you get to installing more binaries and libraries onto your machine,
each of which have different versions, configuration options, etc. &lt;!--Executing programs can change your filesystem and thus drive.--&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;optimizing-our-reproduction&quot;&gt;Optimizing our Reproduction&lt;a class=&quot;zola-anchor&quot; href=&quot;#optimizing-our-reproduction&quot; aria-label=&quot;Anchor link for: optimizing-our-reproduction&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Now that we&#x27;ve gained an appreciation for the amount of things that can go wrong on a computer,
let&#x27;s try to replicate program behaviour from one computer on another by replicating their environment!&lt;&#x2F;p&gt;
&lt;p&gt;We start with first obtaining a dump of the hard disk used in the original, plug it in, and boot our second computer from it.
And we&#x27;re done!&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;... that was awfully easy. What&#x27;s the catch?&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;The catch? I&#x27;m glad you noticed. The catch is that most server (read: bare-bones) operating systems take anywhere from a gigabyte to three-and-a-half gigabytes. And that&#x27;s not accounting for additional libraries and packages that you install to run your program. Overall, the amount of data you need to transfer is &lt;em&gt;a lot&lt;&#x2F;em&gt;. Additionally, booting from the copied disk is much more restrictive than the approach we&#x27;re going to discuss next.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;user-space-and-kernels&quot;&gt;User space and Kernels&lt;a class=&quot;zola-anchor&quot; href=&quot;#user-space-and-kernels&quot; aria-label=&quot;Anchor link for: user-space-and-kernels&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Quick revision:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;The kernel is the core of the operating system:
it manages the most basic operations that processes require, such as memory allocation, disk management, etc.&lt;&#x2F;li&gt;
&lt;li&gt;Programs call into the kernel for many operations, such as allocating memory, accessing system resources, etc.&lt;&#x2F;li&gt;
&lt;li&gt;Programs and the kernel communicate through the &lt;abbr title=&quot;Application Binary Interface&quot;&gt;ABI&lt;&#x2F;abbr&gt;.
In the case where ABI expectations do not match (i.e. the program was compiled with the expectation of a different layout), &lt;em&gt;bad things happen&lt;&#x2F;em&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;We could make reproducibility &lt;em&gt;much&lt;&#x2F;em&gt; easier if we used the same kernel as the host system. That way, all we&#x27;d have to do is mount another filesystem to the host (which contains the filesystem from the original computer), isolate it sufficiently, and we&#x27;d have replicated program behaviour &lt;em&gt;if&lt;&#x2F;em&gt; there are no kernel problems.&lt;&#x2F;p&gt;
&lt;p&gt;For our case, that&#x27;s a worthwhile trade. As long as the kernel for which the programs on the original were compiled for is compatible with your host,
you can replicate program behaviour with minimal overhead. One of the most popular kernels out there, Linux, has a long history of backwards compatibility, which makes it a good fit.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;The above-mentioned constraint of having the same kernel or same processor architecture can be worked around with emulation.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#2&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Linux has a handy feature called &lt;code&gt;namespaces&lt;&#x2F;code&gt;, which enables effective isolation of userspace. Combined with other kernel functionality, Docker can reproduce program behaviour from a Linux machine on any other machines running sufficiently-compatible Linux versions.&lt;&#x2F;p&gt;
&lt;p&gt;While I would love to discuss the exact manner of how Docker interacts with Linux in order to accomplish that, at this point in time, I don&#x27;t think I can do better than &lt;a href=&quot;https:&#x2F;&#x2F;www.redhat.com&#x2F;en&#x2F;blog&#x2F;architecting-containers-part-1-why-understanding-user-space-vs-kernel-space-matters&quot;&gt;Red Hat&#x27;s explanation.&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;further-optimization&quot;&gt;Further Optimization&lt;a class=&quot;zola-anchor&quot; href=&quot;#further-optimization&quot; aria-label=&quot;Anchor link for: further-optimization&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;So far, we&#x27;ve gotten down to replicating the environment of the host computer efficiently. Our next question is whether we can optimize the size of the environment itself. We can do that by building our environment up from scratch to only contain relevant dependencies, instead of trying to replicate everything from the host system.
Dockerfiles and other &quot;infrastructure as code&quot; software attempts to automate that process. (Most of them are glorified bash scripts run in fresh distros - but hey, that&#x27;s a mainstream and perfectly valid approach to setting up a system.)&lt;&#x2F;p&gt;
&lt;p&gt;There are many more innovations in this domain, which we won&#x27;t be discussing here. Normally, at this point, I would move on to properly introducing containers, images, but...&lt;&#x2F;p&gt;
&lt;h2 id=&quot;not-a-docker-tutorial&quot;&gt;Not a Docker Tutorial&lt;a class=&quot;zola-anchor&quot; href=&quot;#not-a-docker-tutorial&quot; aria-label=&quot;Anchor link for: not-a-docker-tutorial&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;There are already enough Docker tutorials in the world that I really don&#x27;t think it needs another. This article was written primarily to showcase the &quot;number of states&quot; insight, and the rest about Docker and reproducibility grew around that. If you still think that a Docker tutorial would be useful, feel free to &lt;a href=&quot;mailto:sendtokartavya@gmail.com&quot;&gt;write to me&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;I &lt;em&gt;will&lt;&#x2F;em&gt; leave you with a taste of that, however:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
Container images become containers at runtime and in the case of Docker containers – images become containers when they run on Docker Engine. Available for both Linux and Windows-based applications, containerized software will always run the same, regardless of the infrastructure. Containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development and staging.&lt;sup&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.docker.com&#x2F;resources&#x2F;what-container&#x2F;&quot;&gt;3&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Oh, and &lt;a href=&quot;https:&#x2F;&#x2F;opencontainers.org&#x2F;about&#x2F;overview&#x2F;&quot;&gt;there&#x27;s a world of containerization outside Docker,&lt;&#x2F;a&gt; in case you&#x27;re interested.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;further-reading&quot;&gt;Further Reading&lt;a class=&quot;zola-anchor&quot; href=&quot;#further-reading&quot; aria-label=&quot;Anchor link for: further-reading&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;1&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;1&lt;&#x2F;sup&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rule_of_product&quot;&gt;Rule of product (Combinatorics)&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;2&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;2&lt;&#x2F;sup&gt;
&lt;p&gt;An example: &lt;a href=&quot;https:&#x2F;&#x2F;www.docker.com&#x2F;blog&#x2F;multi-arch-images&#x2F;&quot;&gt;Multi-arch images&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>How I Wrote This Blog</title>
        <published>2022-01-26T00:00:00+00:00</published>
        <updated>2022-01-26T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.vashishtha.in/this-blog/"/>
        <id>https://blog.vashishtha.in/this-blog/</id>
        
        <content type="html" xml:base="https://blog.vashishtha.in/this-blog/">&lt;h1 id=&quot;the-journey&quot;&gt;The Journey:&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-journey&quot; aria-label=&quot;Anchor link for: the-journey&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;I&#x27;d gotten the itch to write stuff of my own sometime last year after reading &lt;em&gt;way&lt;&#x2F;em&gt; too many technical blogs for
&quot;fun and profit&quot;.&lt;&#x2F;p&gt;
&lt;p&gt;One of said blogs was &lt;a href=&quot;https:&#x2F;&#x2F;www.ecorax.net&#x2F;&quot;&gt;cuervo&#x27;s blog&lt;&#x2F;a&gt;, which I really liked - their theme felt easy on the eyes. Their website also included a RSS feed, which I &lt;em&gt;loved&lt;&#x2F;em&gt;. &lt;small&gt;(Since I use RSS with Thunderbird to keep up with blogs)&lt;&#x2F;small&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The first step was getting acquainted with the SSG (Static Site Generator)&lt;sup&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.cloudflare.com&#x2F;en-in&#x2F;learning&#x2F;performance&#x2F;static-site-generator&#x2F;&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; of my choice, &lt;a href=&quot;https:&#x2F;&#x2F;www.getzola.org&#x2F;&quot;&gt;Zola&lt;&#x2F;a&gt;. I picked Zola for two reasons: the theme I liked (cuervo&#x27;s blog) was a Zola theme, and Zola was written in Rust. (Being written Rust was an advantage because I was reasonably proficient in Rust and could modify the codebase if push came to shove)&lt;&#x2F;p&gt;
&lt;!--
Back in ye olden days, blogs and such would be directly written in HTML&#x2F;CSS. (Oh, the horror!) Thankfully, someone had the idea for using a database for storing the actual content (articles, photos, etc.) and dynamically building 
--&gt;
&lt;p&gt;It turned out that the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;PabloMansanet&#x2F;zerm&quot;&gt;theme cuervo&#x27;s blog used&lt;&#x2F;a&gt; (&quot;zerm&quot;) was a fork of the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;ejmg&#x2F;zerm&quot;&gt;actual zerm theme&lt;&#x2F;a&gt;, which in turn was a port of Radek Kozieł&#x27;s &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;panr&#x2F;hugo-theme-terminal&quot;&gt;Terminal theme&lt;&#x2F;a&gt; for Hugo.&lt;&#x2F;p&gt;
&lt;p&gt;After going through Zola&#x27;s documentation, I forked curveo (a.k.a PabloMansanet)&#x27;s theme and got to work.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;teething-troubles&quot;&gt;Teething Troubles&lt;a class=&quot;zola-anchor&quot; href=&quot;#teething-troubles&quot; aria-label=&quot;Anchor link for: teething-troubles&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;!--
There were a few stumbling blocks along the way of setting up a basic &quot;Hello World&quot;, such as nesting sections and getting articles to show up on my home page.

I set up taxonomies; reading the configuration file thoroughly enough helped. (Taxonomies are the system which allows for adding &quot;tags&quot; or &quot;category&quot; to articles.) Eventuall, I got comfortable enough with Zola that I edited the social bar to be customizable.
--&gt;
&lt;p&gt;I distinctly remembered reading about &lt;a href=&quot;https:&#x2F;&#x2F;katex.org&quot; alt=&quot;KaTeX website&quot;&gt;$\KaTeX$&lt;&#x2F;a&gt; support in the README of the theme, and loved how it looked. However, on uncommenting the flag in my &lt;code&gt;config.toml&lt;&#x2F;code&gt;, nothing happened. This took me some time to pin down, but it turned out that I had somehow taken &lt;code&gt;config.toml&lt;&#x2F;code&gt; from the original &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;ejmg&#x2F;zerm&quot;&gt;zerm repository&lt;&#x2F;a&gt;, while using the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;PabloMansanet&#x2F;zerm&quot;&gt;zerm fork&lt;&#x2F;a&gt;. $\KaTeX$ support was merged in later, once the repository had already been forked. 🤦‍♂️  I got it working once I synced with the original repository.&lt;&#x2F;p&gt;
&lt;p&gt;Next, diagrams. I had seen some of the (frankly gorgeous) diagrams in &lt;a href=&quot;https:&#x2F;&#x2F;cses.fi&#x2F;book&#x2F;index.php&quot;&gt;Competitive Programmer&#x27;s Handbook&lt;&#x2F;a&gt; and wanted something similar. Luckily, the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;pllk&#x2F;cphb&#x2F;&quot;&gt;book&#x27;s source&lt;&#x2F;a&gt; was available over at GitHub. The book used $\LaTeX$ (a typesetting language) with the pgf&#x2F;Tikz library for illustrations. ($\LaTeX$ is what $\KaTeX$ is a subset of, and despite the similar names, the former is by &lt;em&gt;far&lt;&#x2F;em&gt; larger)&lt;&#x2F;p&gt;
&lt;p&gt;To my own surprise, I had &lt;a href=&quot;https:&#x2F;&#x2F;miktex.org&#x2F;&quot;&gt;MikTex&lt;&#x2F;a&gt; (a latex distribution) along with TeXworks (a latex IDE) installed on Windows. It seems that past me had at once point set all this up and never done anything with it.&lt;&#x2F;p&gt;
&lt;p&gt;After copy-pasting a diagram into TeXworks, I was rather surprised - &lt;a href=&quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;this-blog&#x2F;illustrations&#x2F;array-diagram.pdf&quot;&gt;it worked perfectly&lt;&#x2F;a&gt;. Which basically never happens. I quickly noticed that it was currently producing a full page pdf, which was not something I wanted, and thus all was right with world.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;descent-into-madness&quot;&gt;Descent into Madness&lt;a class=&quot;zola-anchor&quot; href=&quot;#descent-into-madness&quot; aria-label=&quot;Anchor link for: descent-into-madness&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;I wanted to achieve complete automation of my build process - so I started writing shell scripts to do all the hard work for me. Along the way, I committed multiple war crimes.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: The term &quot;War Crime&quot; is used in further sections to humorously highlight bad practices.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h4 id=&quot;war-crime-one&quot;&gt;War crime One&lt;a class=&quot;zola-anchor&quot; href=&quot;#war-crime-one&quot; aria-label=&quot;Anchor link for: war-crime-one&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;I couldn&#x27;t get LaTeX working on &lt;a href=&quot;https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;windows&#x2F;wsl&#x2F;about&quot;&gt;WSL&lt;&#x2F;a&gt;. Everytime I ran the install script for &lt;a href=&quot;https:&#x2F;&#x2F;tug.org&#x2F;texlive&#x2F;quickinstall.html&quot;&gt;tex-live&lt;&#x2F;a&gt; I would miss something in the configuration. The first time, I included everything and set it to install, only noting later that the entirety of Tex-Live seemed to be 7 GB in size.&lt;&#x2F;p&gt;
&lt;p&gt;The next time, &lt;code&gt;latex&lt;&#x2F;code&gt; didn&#x27;t install. &lt;code&gt;tex&lt;&#x2F;code&gt; and its &lt;em&gt;many&lt;&#x2F;em&gt; &lt;em&gt;many&lt;&#x2F;em&gt; cousins installed, but no mention of latex.
One more try; this time, &lt;em&gt;nothing&lt;&#x2F;em&gt; worked. I was fed up, and committed &quot;war-crime&quot; one:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;pdflatex&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;quiet&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;which was calling latex from windows in WSL.&lt;&#x2F;p&gt;
&lt;p&gt;Now I had a way to produce a PDF from my &lt;code&gt;.tex&lt;&#x2F;code&gt; files.&lt;&#x2F;p&gt;
&lt;!-- By now, I had a skeleton of my article written down with some supporting diagrams. --&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;The original LaTeX code had lots hard-coded coordinates which I didn&#x27;t like, since I felt that they made the overall diagram difficult to parse. Something like:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;latex&quot; class=&quot;language-latex z-code&quot;&gt;&lt;code class=&quot;language-latex&quot; data-lang=&quot;latex&quot;&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-begin z-latex&quot;&gt;&lt;span class=&quot;z-keyword z-control z-flow z-begin z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;begin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-function z-latex&quot;&gt;center&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-begin z-latex&quot;&gt;&lt;span class=&quot;z-keyword z-control z-flow z-begin z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;begin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-function z-latex&quot;&gt;tikzpicture&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-bracket z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-bracket z-begin z-latex&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-bracket z-latex&quot;&gt;scale&lt;&#x2F;span&gt;=0.7&lt;span class=&quot;z-punctuation z-definition z-group z-bracket z-end z-latex&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;draw&lt;&#x2F;span&gt; (0,0) grid (8,1);
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (0.5,0.5) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;5&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (1.5,0.5) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;8&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (2.5,0.5) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;6&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (3.5,0.5) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;3&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (4.5,0.5) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (5.5,0.5) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;7&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (6.5,0.5) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (7.5,0.5) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;6&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;footnotesize&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (0.5,1.4) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;0&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (1.5,1.4) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (2.5,1.4) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (3.5,1.4) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;3&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (4.5,1.4) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;4&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (5.5,1.4) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;5&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (6.5,1.4) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;6&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (7.5,1.4) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-environment z-math z-inline z-dollar z-latex&quot;&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-math z-tex&quot;&gt;7&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-other z-math z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-latex&quot;&gt;$&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-end z-latex&quot;&gt;&lt;span class=&quot;z-keyword z-control z-flow z-end z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-function z-latex&quot;&gt;tikzpicture&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-end z-latex&quot;&gt;&lt;span class=&quot;z-keyword z-control z-flow z-end z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-function z-latex&quot;&gt;center&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After reading the &lt;a href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20211128100941&#x2F;https:&#x2F;&#x2F;www.bu.edu&#x2F;math&#x2F;files&#x2F;2013&#x2F;08&#x2F;tikzpgfmanual.pdf&quot;&gt;entire chapter on the Tikz Mathematical Engine in the Tikz guide&lt;&#x2F;a&gt; three times (and many StackOverflow answers), I managed to get a counting loop working.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;latex&quot; class=&quot;language-latex z-code&quot;&gt;&lt;code class=&quot;language-latex&quot; data-lang=&quot;latex&quot;&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-begin z-latex&quot;&gt;&lt;span class=&quot;z-keyword z-control z-flow z-begin z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;begin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-function z-latex&quot;&gt;center&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;tikz&lt;&#x2F;span&gt;[scale=0.7, frontmatter]
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;	&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;pgfmathresultunitscale&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;1&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;	&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;draw&lt;&#x2F;span&gt; (0,0) grid (8,1);
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;	&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;foreach&lt;&#x2F;span&gt;[count=&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt;, evaluate=&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt; as &lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;x&lt;&#x2F;span&gt; using (&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt;-0.500)] &lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;n&lt;&#x2F;span&gt; in &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;4, 3, 2, 8, 5, 1, 2, 1&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;		&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;x&lt;&#x2F;span&gt;,0.5) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;		&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;node&lt;&#x2F;span&gt; at (&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;x&lt;&#x2F;span&gt;,1.4) &lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-general z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;	&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-meta z-group z-brace z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-end z-latex&quot;&gt;&lt;span class=&quot;z-keyword z-control z-flow z-end z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-function z-latex&quot;&gt;center&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-text z-tex z-latex&quot;&gt;&lt;span class=&quot;z-support z-function z-end z-latex&quot;&gt;&lt;span class=&quot;z-keyword z-control z-flow z-end z-latex&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-backslash z-latex&quot;&gt;\&lt;&#x2F;span&gt;end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-begin z-latex&quot;&gt;{&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-function z-latex&quot;&gt;document&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-group z-brace z-end z-latex&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;There are two really nice things about latex:&lt;br&gt;
(1) the &quot;ecosystem&quot; has had time to develop, and there is no lack of resources for troubleshooting highly-specific problems.&lt;br&gt;
(2) the documentation for everything is &lt;em&gt;super pretty&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;My next endeavor was getting &lt;code&gt;latex&lt;&#x2F;code&gt; to produce &lt;code&gt;.svg&lt;&#x2F;code&gt; files - they would be perfect for scalability. I recalled seeing svgs which could adjust their color based on browser theme to adapt their colors, which sounded great, considering that the current output of &lt;code&gt;pdflatex&lt;&#x2F;code&gt; in PDF viewers was near invisible, since I was building my diagrams for a website with a &lt;em&gt;dark&lt;&#x2F;em&gt; background, while the PDF had a &lt;em&gt;white&lt;&#x2F;em&gt; background.&lt;&#x2F;p&gt;
&lt;p&gt;I quickly found &lt;code&gt;dvisvgm.exe&lt;&#x2F;code&gt; for the task, and after some minor teething troubles (which was a constant in my life by that point), got it running.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;war-crime-two&quot;&gt;War crime Two&lt;a class=&quot;zola-anchor&quot; href=&quot;#war-crime-two&quot; aria-label=&quot;Anchor link for: war-crime-two&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;Once I had a &lt;code&gt;.svg&lt;&#x2F;code&gt; file to embed in my web page, I tried to get it to size properly. The output looked ridiculously small on my desktop monitor.
&lt;code&gt;dvisvgm.exe&lt;&#x2F;code&gt; produces output along the lines of:&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;svg&quot; class=&quot;language-svg z-code&quot;&gt;&lt;code class=&quot;language-svg&quot; data-lang=&quot;svg&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-preprocessor z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;?&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-xml&quot;&gt;xml&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;version&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;1.0&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;encoding&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;UTF-8&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;?&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-comment z-block z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-begin z-xml&quot;&gt;&amp;lt;!--&lt;&#x2F;span&gt; This file was generated by dvisvgm 2.11.1 &lt;span class=&quot;z-punctuation z-definition z-comment z-end z-xml&quot;&gt;--&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;&lt;mark&gt;3&lt;&#x2F;mark&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;mark&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;svg&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;version&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;1.1&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;xmlns&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;http:&#x2F;&#x2F;www.w3.org&#x2F;2000&#x2F;svg&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-namespace z-xml&quot;&gt;xmlns&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-other z-attribute-name z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-namespace z-xml&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;xlink&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xlink&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;width&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;159.140599pt&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;height&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;31.511983pt&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;viewBox&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;154.429651 2.995859 159.140599 31.511983&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;mark&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;style&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;type&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;text&#x2F;css&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;5&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-sgml z-cdata z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;![&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-declaration z-cdata z-xml&quot;&gt;CDATA&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;[&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-tag z-sgml z-cdata z-xml&quot;&gt;&lt;span class=&quot;z-string z-unquoted z-cdata z-xml&quot;&gt;@font-face{font-family:cmr10;src:url(data:application&#x2F;x-font-ttf;base64,AAEAAAANAI... format(&amp;#39;truetype&amp;#39;);}
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-sgml z-cdata z-xml&quot;&gt;&lt;span class=&quot;z-string z-unquoted z-cdata z-xml&quot;&gt;text.f0 {font-family:cmr10;font-size:9.96264px}
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-sgml z-cdata z-xml&quot;&gt;&lt;span class=&quot;z-string z-unquoted z-cdata z-xml&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;]]&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;style&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;g&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;id&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;page1&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;path&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;d&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;M154.628901 34.308592H313.371M154.628901 14.4727H313.371M154.628901 34.308592V14.4687M174.4727 34.308592V14.4687M194.3164 34.308592V14.4687M214.1562 34.308592V14.4687M234 34.308592V14.4687M253.8437 34.308592V14.4687M273.687 34.308592V14.4687M293.527 34.308592V14.4687M313.363 34.308592V14.4687&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;stroke&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;#373737&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;fill&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;none&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;stroke-width&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;.3985&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&#x2F;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;text&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;class&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;f0&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;x&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;154.630296&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;y&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;34.309967&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;transform&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;matrix(1 0 0 1 7.431 -6.7111)&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;tspan&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-other z-attribute-name z-localname z-xml&quot;&gt;fill&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-xml&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;#373737&lt;span class=&quot;z-punctuation z-definition z-string z-end z-xml&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;4&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;tspan&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;text&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;g&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-text z-xml&quot;&gt;&lt;span class=&quot;z-meta z-tag z-xml&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-begin z-xml&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-tag z-localname z-xml&quot;&gt;svg&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-tag z-end z-xml&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I identified that &lt;code&gt;&amp;lt;svg&amp;gt;&lt;&#x2F;code&gt; wouldn&#x27;t inherit any sizing until I deleted the &lt;code&gt;width&lt;&#x2F;code&gt; and &lt;code&gt;height&lt;&#x2F;code&gt; attributes included in the third line. I&#x27;ll be the first to admit that I &lt;em&gt;really don&#x27;t have experience with the front-end.&lt;&#x2F;em&gt;
So... war crime.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;sed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;3 {s&#x2F;width=&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape z-shell&quot;&gt;\&amp;#39;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;[^&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape z-shell&quot;&gt;\&amp;#39;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;]*&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape z-shell&quot;&gt;\&amp;#39;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&#x2F;&#x2F;;s&#x2F;height=&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape z-shell&quot;&gt;\&amp;#39;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;[^&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape z-shell&quot;&gt;\&amp;#39;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;]*&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape z-shell&quot;&gt;\&amp;#39;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&#x2F;&#x2F;;};&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt; array-diagram.svg&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;The above snippet looks at line number 3, and substitutes the text matching the patterns
&lt;code&gt;width=&#x27;[^&#x27;]*&#x27;&lt;&#x2F;code&gt; and &lt;code&gt;height=&#x27;[^&#x27;]*&#x27;&lt;&#x2F;code&gt; with nothing. This sed invocation will transform &lt;code&gt;width=&#x27;foo&#x27; irrelevant info=&#x27;bar&#x27; height=&#x27;qux&#x27;&lt;&#x2F;code&gt; (at line 3) to &lt;code&gt;irrelevant info=&#x27;bar&#x27;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Sizing works now! I even got an easily-controllable size slider in the form of &lt;code&gt;width = x%&lt;&#x2F;code&gt; with CSS.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;war-crime-three&quot;&gt;War crime Three&lt;a class=&quot;zola-anchor&quot; href=&quot;#war-crime-three&quot; aria-label=&quot;Anchor link for: war-crime-three&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;This one has a bit of a story behind it. See, the LaTeX library I was using didn&#x27;t have something similar to an erase option. I drew my indices on top of existing markings, so they overlapped like so:&lt;&#x2F;p&gt;


&lt;figure class=&quot;size-medium center&quot;&gt;&lt;!--Add proper accessibility to svgs: https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;4756461&#x2F;10147642 - if you&#x27;re reading this in DevTools, and have an idea of how to, feel free to write to me!--&gt;
	
	&lt;?xml version=&#x27;1.0&#x27; encoding=&#x27;UTF-8&#x27;?&gt;
&lt;!-- This file was generated by dvisvgm 3.2.2 --&gt;
&lt;svg version=&#x27;1.1&#x27; xmlns=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;2000&#x2F;svg&#x27; xmlns:xlink=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xlink&#x27;   viewBox=&#x27;154.429651 -.00025 159.140599 134.304966&#x27;&gt;
&lt;style type=&#x27;text&#x2F;css&#x27;&gt;
&lt;![CDATA[@font-face{font-family:cmr10;src:url(data:application&#x2F;x-font-ttf;base64,AAEAAAAKAIAAAwAgT1MvMoVLdCkAAACsAAAAYGNtYXAADACMAAABDAAAADRnbHlm14gP0wAAAUAAAAYUaGVhZCftHksAAAdUAAAANmhoZWEFEAGSAAAHjAAAACRobXR4BZ0AzQAAB7AAAAAabG9jYQcUCJYAAAfMAAAAGG1heHAADwBAAAAH5AAAACBuYW1lguMqqQAACAQAAAE4cG9zdAADAAEAAAk8AAAAIAADAgsBkAAFAAACmgLN&#x2F;hQAjwKaAs0B7AHsADMBCQAAAAAGAAAAAAAAAAAAAAEAAAAAAAAAAAAAAABkc3ZnAAYAMAA5AwD&#x2F;AAAAAwABAAAAAAEAAAAAAAAAAAAA&#x2F;&#x2F;8AAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAIAAAAAQABAABAAAAOf&#x2F;&#x2F;AAAAMP&#x2F;&#x2F;&#x2F;9EAAQAAAAAAAgAn&#x2F;+cB2AKsABYALgAAARYGBw4BJwYmJy4BNDY3PgEXNhYXHgEDFjY3Ni8BJicuAQcmDwEGBwYfARYXHgEB1wEPGCRjKydfIx8QDxghYi8jZSYaENkkRg4OAwECBxJLHBYmBiYSCgIBAggQRwFIPXU2RzICASw9O4F4djVGNQECLUg5ef57ATlIYXNmNixJMQMEFgMYVlZmbDwwSTQAAAEAWwAAAa0CqwAYAAABEQYWOwEVJyMHNTMyNicRDgEnNRY2NzYWAS0DIEIhUapRIUMfAylMERxsMxEHAo&#x2F;9whwVIAMDIBUcAhITCAEfAhUvAQoAAAEAMwAAAc0CqgArAAA3Mzc2NzY&#x2F;ATMHITc2PwE+ATc0JiciBgc3HgEVDgEnBiYnPgE3HgEXFgcGB4K4NyIJBwYJGh3+hAECCMUsPwFERi1KEw0bHAIlDwUuAwFnWF94AgEzNnVPAQEGDRszshgHB9swdT1CYwI2MgEBIBQfGQECEylHbwMBbVlIPj9mAAAAAAEAK&#x2F;&#x2F;pAdQCqQA3AAABHgEXDgEHLgEnPgEXMhYUBiceAjY3NCYnIwY2FzcWPgInLgEHJgYHNhYXFAYjJic+ATIeAQYBKVFZAQJ5X1Z3AgElExghJxweXEhLAzs+LRoDDSgUMCsKAQI+Ih5RGQ4vAhwYMAQCZJxtAU4BaBFnQVFyAwFZRyIbAR45HgMsIwFFZk1cAQMcAQMBEkhFDEMwAQEbJQIQJRceATU7T019YQAAAgAdAAAB4gK4ABoAHQAAJSE1ATYXMhYHETMVIxUGFjsBFScjBzUzMjYnNxEDAS3+8AE6CQwMBQFmZgIZNxVFjEQVNxkCBvqpIAHgDwMLD&#x2F;4uIFkcFCADAyAUHHkBfv6CAAAAAAEAM&#x2F;&#x2F;pAcwCqgA9AAAlDgEHLgEnPgEXHgEUBgciJx4BFzY3PgEnNicuAScOAQcGIyI3ESYzNhcWNz4BPwEWFRQPAQYHJicVNhceAQHMA4BcV2IBAiQMGhoaGg4DDlA4SCYRCQEDFgYpKD0&#x2F;CAQJEgMCDQIKSj40SA8JCiwQM1c0IzhKVWzOZH4DBHJGIxQBAR4mHgECL0MBA0AhTh1LNhAwAgQ1DwkaAS8ZAQQfAgEVCAMBCg4nDCYEAgzINQEDfwAAAAACACv&#x2F;5gHUAqoAKAA8AAATPgE3HgEXDgEHBicmJyYnNj8BNjceARUOAS4BJz4BFy4BByYHBgcGBxMWNjc+ATQmJy4BBw4BFwYWFx4BhxA8NFd0AgJ5WEM+Dg03AwRNCVBjQEIBIB8dAQIpDRI0FCE0GBcsA3oSOxgNBgYOGTkNRDoBAQYOBDEBUCc8AgJ&#x2F;Y2h9AwM7DhNNtaReDFcBAT8vHRUBGBchDgEaEAEDHxMiP5j+ngIZLBxIS0ocLhQCBHNAEF0nDzsAAAEAOf&#x2F;pAfECtAAhAAABBw4BBwYdARYGBy4BNyY2PwIFBgcGDwEjNzMGFjsBBwYB54ohHAIMAQ4iIQ8BATtESCv++CcJCwYJGiIaASpa+QECAnDDMmkUU1U0CiwDAywKUMdqZT0BAQUMITDTDhMVBgADACv&#x2F;6QHVAqoACwApADUAABMXPgE3LgEiBgcGFh8BFhceAQcOAQcuASc+ATcnJicuATc+ATceARcOAQcOARceATI2Ny4BJ6d&#x2F;LzUBAlFxUQIBErdEFA4cFwECellUfQMEXzArFgkfDwECaE9JbAMBQp9AOQECXIZdAgIzGAHUUhtILDlFOS8NLnksDw4hQRxUbAMBX1JLXBUeDwolPg5JYAIBUEgzT0clWy1CUkc5LjQPAAACACv&#x2F;6QHUAq0AKQA+AAABDgEHLgEnNDY3Nhc2FxYXFhcOAQciJic+ARcyFhcWBgceATcWNzY3NjcHPgEnNCYnLgEnJgYHDgEXBhYXHgEBeBI&#x2F;L1hzAiIgQlRAPA8ONQMEl2ZCSwEBIA4RHQEBFiAWPw8qMQ4OLAN&#x2F;QjwBBwoNMSQcNRUQBwEBBg4ZOQFGLTkBAoBjOEwhQwIDNxAVTbOnvgM7NB4UARcYDiABGgwBAykOFT2ZLgNyQyVSGSMtAQEbJh1GKiZJHS4UAAABAAAAAQAAcpK4o18PPPUAAwQAAAAAAOMq7VgAAAAA4yrtWAAA&#x2F;+YCgAK4AAAACAACAAAAAAAAAAEAAAMA&#x2F;wAAAAKAAB0ADwHxAAEAAAAAAAAAAAAAAAAAAAACAoAAAAIAACcAWwAzACsAHQAzACsAOQArACsAAAAAAAAAUAB6AMIBGgFMAa4CEgJKAqQDCgABAAAACwA&#x2F;AAMAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgB+AAEAAAAAAAEADwAAAAEAAAAAAAQABQAPAAEAAAAAAAUACwAUAAEAAAAAAAYABQAfAAEAAAAAAAoAGgAkAAMAAQQJAAEAHgA+AAMAAQQJAAQACgBcAAMAAQQJAAUAFgBmAAMAAQQJAAYACgB8AAMAAQQJAAoANACGQ29tcHV0ZXIgTW9kZXJuY21yMTBWZXJzaW9uIDEuMGNtcjEwR2VuZXJhdGVkIGJ5IGR2aXN2Z20gMy4yLjIAQwBvAG0AcAB1AHQAZQByACAATQBvAGQAZQByAG4AYwBtAHIAMQAwAFYAZQByAHMAaQBvAG4AIAAxAC4AMABjAG0AcgAxADAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABkAHYAaQBzAHYAZwBtACAAMwAuADIALgAyAAMAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=) format(&#x27;truetype&#x27;);}
text.f0 {font-family:cmr10;font-size:9.96264px}
]]&gt;
&lt;&#x2F;style&gt;
&lt;g id=&#x27;page1&#x27;&gt;
&lt;path d=&#x27;M154.628901 134.105466H313.371M154.628901 114.2695H313.371M154.628901 134.105466V114.2617M174.4727 134.105466V114.2617M194.3164 134.105466V114.2617M214.1562 134.105466V114.2617M234 134.105466V114.2617M253.8437 134.105466V114.2617M273.687 134.105466V114.2617M293.527 134.105466V114.2617M313.363 134.105466V114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 7.431 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 27.273 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 47.116 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 66.959 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 86.801 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 106.644 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 126.487 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 146.329 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M183.2266 84.5C183.2266 79.6641 179.3086 75.7461 174.4727 75.7461C169.6367 75.7461 165.7187 79.6641 165.7187 84.5C165.7187 89.332 169.6367 93.2539 174.4727 93.2539C179.3086 93.2539 183.2266 89.332 183.2266 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 17.352 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M171.6406 92.9922L164.55078 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M177.3047 92.9922L184.3945 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 84.5C222.9102 79.6641 218.9922 75.7461 214.1562 75.7461C209.3242 75.7461 205.4062 79.6641 205.4062 84.5C205.4062 89.332 209.3242 93.2539 214.1562 93.2539C218.9922 93.2539 222.9102 89.332 222.9102 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 57.037 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M211.3281 92.9922L204.2383 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M216.9883 92.9922L224.0781 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.598 84.5C262.598 79.6641 258.676 75.7461 253.8437 75.7461C249.0078 75.7461 245.0898 79.6641 245.0898 84.5C245.0898 89.332 249.0078 93.2539 253.8437 93.2539C258.676 93.2539 262.598 89.332 262.598 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 96.723 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M251.0156 92.9922L243.9219 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M256.676 92.9922L263.766 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M302.281 84.5C302.281 79.6641 298.363 75.7461 293.527 75.7461C288.695 75.7461 284.777 79.6641 284.777 84.5C284.777 89.332 288.695 93.2539 293.527 93.2539C298.363 93.2539 302.281 89.332 302.281 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 136.408 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M290.699 92.9922L283.609 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M296.363 92.9922L303.449 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M168.4883 113.2695C168.4883 111.0977 166.7266 109.332 164.55078 109.332C162.375 109.332 160.61328 111.0977 160.61328 113.2695C160.61328 115.4453 162.375 117.2109 164.55078 117.2109C166.7266 117.2109 168.4883 115.4453 168.4883 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 93.8475 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.332 113.2695C188.332 111.0977 186.5703 109.332 184.3945 109.332S180.457 111.0977 180.457 113.2695C180.457 115.4453 182.2187 117.2109 184.3945 117.2109S188.332 115.4453 188.332 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 113.6895 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M208.9961 113.2695C208.9961 110.6445 206.8633 108.5117 204.2383 108.5117C201.6094 108.5117 199.4805 110.6445 199.4805 113.2695C199.4805 115.8984 201.6094 118.0273 204.2383 118.0273C206.8633 118.0273 208.9961 115.8984 208.9961 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 132.4115 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;10&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M228.8359 113.2695C228.8359 110.6445 226.707 108.5117 224.0781 108.5117C221.4531 108.5117 219.3203 110.6445 219.3203 113.2695C219.3203 115.8984 221.4531 118.0273 224.0781 118.0273C226.707 118.0273 228.8359 115.8984 228.8359 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 152.2545 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;11&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M248.6797 113.2695C248.6797 110.6445 246.5508 108.5117 243.9219 108.5117S239.1641 110.6445 239.1641 113.2695C239.1641 115.8984 241.293 118.0273 243.9219 118.0273S248.6797 115.8984 248.6797 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 172.0965 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;12&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M268.523 113.2695C268.523 110.6445 266.395 108.5117 263.766 108.5117S259.008 110.6445 259.008 113.2695C259.008 115.8984 261.137 118.0273 263.766 118.0273S268.523 115.8984 268.523 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 191.9395 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;13&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M288.367 113.2695C288.367 110.6445 286.234 108.5117 283.609 108.5117C280.98 108.5117 278.848 110.6445 278.848 113.2695C278.848 115.8984 280.98 118.0273 283.609 118.0273C286.234 118.0273 288.367 115.8984 288.367 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 211.7825 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;14&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M308.207 113.2695C308.207 110.6445 306.078 108.5117 303.449 108.5117C300.824 108.5117 298.691 110.6445 298.691 113.2695C298.691 115.8984 300.824 118.0273 303.449 118.0273C306.078 118.0273 308.207 115.8984 308.207 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 231.6245 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;15&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M204.8203 54.7344C204.8203 48.9336 200.1172 44.2305 194.3164 44.2305S183.8125 48.9336 183.8125 54.7344S188.5156 65.2383 194.3164 65.2383S204.8203 60.5352 204.8203 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 5.771 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.3555 63.6719L179.4375 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M200.2773 63.6719L209.1953 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M284.191 54.7344C284.191 48.9336 279.488 44.2305 273.687 44.2305C267.887 44.2305 263.184 48.9336 263.184 54.7344S267.887 65.2383 273.687 65.2383C279.488 65.2383 284.191 60.5352 284.191 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 85.141 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M267.73 63.6719L258.812 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M279.648 63.6719L288.566 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M178.4102 75.5703C178.4102 73.3945 176.6484 71.6328 174.4727 71.6328C172.2969 71.6328 170.5352 73.3945 170.5352 75.5703S172.2969 79.5078 174.4727 79.5078C176.6484 79.5078 178.4102 77.7461 178.4102 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 103.7685 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M218.0977 75.5703C218.0977 73.3945 216.332 71.6328 214.1562 71.6328C211.9844 71.6328 210.2187 73.3945 210.2187 75.5703S211.9844 79.5078 214.1562 79.5078C216.332 79.5078 218.0977 77.7461 218.0977 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 143.4535 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M257.781 75.5703C257.781 73.3945 256.02 71.6328 253.8437 71.6328C251.668 71.6328 249.9062 73.3945 249.9062 75.5703S251.668 79.5078 253.8437 79.5078C256.02 79.5078 257.781 77.7461 257.781 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 183.1395 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;6&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M297.469 75.5703C297.469 73.3945 295.703 71.6328 293.527 71.6328C291.352 71.6328 289.59 73.3945 289.59 75.5703S291.352 79.5078 293.527 79.5078C295.703 79.5078 297.469 77.7461 297.469 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 222.8245 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;7&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M244.9414 15.051C244.9414 9.008 240.043 4.109 234 4.109S223.0586 9.008 223.0586 15.051S227.957 25.992 234 25.992S244.9414 21.094 244.9414 15.051Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.25 0 0 1.25 37.5995 -148.5698)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M226.0898 22.961L201.9141 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M241.9141 22.961L266.094 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M198.2539 43.8203C198.2539 41.6445 196.4922 39.8828 194.3164 39.8828S190.375 41.6445 190.375 43.8203S192.1406 47.7617 194.3164 47.7617S198.2539 45.9961 198.2539 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 123.6115 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M277.625 43.8203C277.625 41.6445 275.863 39.8828 273.687 39.8828C271.512 39.8828 269.746 41.6445 269.746 43.8203S271.512 47.7617 273.687 47.7617C275.863 47.7617 277.625 45.9961 277.625 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 202.9815 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M237.9414 4.137C237.9414 1.961 236.1758 .199 234 .199S230.0625 1.961 230.0625 4.137C230.0625 6.312 231.8242 8.074 234 8.074S237.9414 6.312 237.9414 4.137Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 163.2965 -54.76671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;svg&gt;

	
		&lt;figcaption &gt;A Misshapen Tree with Overlapping Markings&lt;&#x2F;figcaption&gt;
	

&lt;&#x2F;figure&gt;
&lt;p&gt;After searching far and wide (even looking at the &lt;a href=&quot;https:&#x2F;&#x2F;mirror.kku.ac.th&#x2F;CTAN&#x2F;graphics&#x2F;pgf&#x2F;base&#x2F;doc&#x2F;pgfmanual.pdf&quot;&gt;updated 1321 page Tikz manual&lt;&#x2F;a&gt;), I came to the conclusion that there was no way to &quot;erase&quot; an area. Sure, there for a few promising leads, but most led to hacks that would only work on specific PDF renderers, etc.&lt;&#x2F;p&gt;
&lt;p&gt;With a heavy heart, I set my index markings to color the area behind them with the background color. This would mean that my hope of easily getting SVGs to adapt to color modes (dark and light) was gone, since the SVG itself would include assumptions about the background color.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash z-code&quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;sed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;9,${
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;	s&#x2F;#373737&#x2F;var(--diagram-frontmatter)&#x2F;;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;	s&#x2F;#dadcec&#x2F;var(--diagram-background)&#x2F;;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;	s&#x2F;#4ba7e3&#x2F;var(--diagram-highlight)&#x2F;;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;	s&#x2F;#9fd6f9&#x2F;var(--diagram-secondary-highlight)&#x2F;;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;};&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;i&lt;&#x2F;span&gt; array-diagram.svg&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;But! Another war crime later, I found I could have my cake and eat it too. Replace all hard coded colors in the SVG with CSS variables! This, incidentally, ensures that I can&#x27;t wrap my &lt;code&gt;&amp;lt;svg&lt;&#x2F;code&gt;&amp;gt; in an &lt;code&gt;&amp;lt;img&amp;gt;&lt;&#x2F;code&gt; tag anymore.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Yes, I am aware of the quote:&lt;br&gt;
Some people, when confronted with a problem, think
“I know, I&#x27;ll use regular expressions.”   Now they have two problems. &quot;
-- &lt;a href=&quot;http:&#x2F;&#x2F;regex.info&#x2F;blog&#x2F;2006-09-15&#x2F;247&quot;&gt;Jamie Zawinski&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;After setting a few CSS variables, my diagrams now scaled with size &lt;em&gt;and&lt;&#x2F;em&gt; adapted to the color theme.&lt;&#x2F;p&gt;
&lt;p&gt;If you&#x27;re feeling curious, this is what they look like on both light and dark mode.&lt;&#x2F;p&gt;
&lt;figure class=&quot;center&quot;&gt;&lt;img src=&quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;this-blog&#x2F;illustrations&#x2F;light.png&quot; alt=&quot;Article on Segment Trees with a light background&quot; &#x2F;&gt;
      &lt;figcaption &gt;Light Mode&lt;&#x2F;figcaption&gt;
   
&lt;&#x2F;figure&gt;&lt;figure class=&quot;center&quot;&gt;&lt;img src=&quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;this-blog&#x2F;illustrations&#x2F;dark.png&quot; alt=&quot;Article on Segment Trees with a dark background&quot; &#x2F;&gt;
      &lt;figcaption &gt;Dark Mode&lt;&#x2F;figcaption&gt;
   
&lt;&#x2F;figure&gt;&lt;h4 id=&quot;intermission-checksum-based-latex-build&quot;&gt;Intermission: Checksum-based $\LaTeX$ build&lt;a class=&quot;zola-anchor&quot; href=&quot;#intermission-checksum-based-latex-build&quot; aria-label=&quot;Anchor link for: intermission-checksum-based-latex-build&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;&lt;code&gt;latex&lt;&#x2F;code&gt; takes a few seconds to compile each TeX file, after which, &lt;code&gt;dvisvgm.exe&lt;&#x2F;code&gt; takes a few more. With the number of diagrams rising so quickly, it was beginning to take about ten seconds for all the diagrams to build. And since I&#x27;m a lazy person who doesn&#x27;t like putting in the name of the diagram I want to build, I wrote a quick-and-dirty checksum-based build system using &lt;code&gt;md5&lt;&#x2F;code&gt;. &lt;small&gt;(side-note: &lt;code&gt;md5&lt;&#x2F;code&gt; is cryptographically unsound, do not use it for security purposes.)&lt;&#x2F;small&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;zsh&quot; class=&quot;language-zsh z-code&quot;&gt;&lt;code class=&quot;language-zsh&quot; data-lang=&quot;zsh&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function z-shell&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-shell&quot;&gt;function&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-name z-function z-shell&quot;&gt;build_latex_file&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-shell&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function z-shell&quot;&gt;	&lt;span class=&quot;z-comment z-line z-number-sign z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-begin z-shell&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-number-sign z-shell&quot;&gt; compile the latex file&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-number-sign z-shell&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function z-shell&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function z-shell&quot;&gt;	&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-echo z-shell&quot;&gt;echo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;:r.svg created&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-and z-shell&quot;&gt;&amp;amp;&amp;amp;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-separator z-continuation z-line z-shell&quot;&gt;\
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function z-shell&quot;&gt;	&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;md5sum&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;:r.checksum&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-braces z-end z-shell&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-loop z-for z-shell&quot;&gt;for&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-for z-shell&quot;&gt; file &lt;span class=&quot;z-keyword z-control z-in z-shell&quot;&gt;in&lt;&#x2F;span&gt; .&#x2F;content&#x2F;&lt;span class=&quot;z-keyword z-operator z-regexp z-quantifier z-shell&quot;&gt;*&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-regexp z-quantifier z-shell&quot;&gt;*&lt;&#x2F;span&gt;&#x2F;&lt;span class=&quot;z-keyword z-operator z-regexp z-quantifier z-shell&quot;&gt;*&lt;&#x2F;span&gt;.tex&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-loop z-do z-shell&quot;&gt;do&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;	&lt;span class=&quot;z-keyword z-control z-conditional z-if z-shell&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;test&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; !&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;f&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;:r.checksum&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-or z-shell&quot;&gt;||&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-shell&quot;&gt;!&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;md5sum&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;c&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;:r.checksum&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;lt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-redirection z-shell&quot;&gt;&amp;amp;&amp;gt;&lt;&#x2F;span&gt; &#x2F;dev&#x2F;null&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-continue z-shell&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-then z-shell&quot;&gt;then&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;		&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;build_latex_file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-expansion z-parameter z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-shell&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other z-readwrite z-shell&quot;&gt;file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;	&lt;span class=&quot;z-keyword z-control z-conditional z-end z-shell&quot;&gt;fi&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-keyword z-control z-loop z-end z-shell&quot;&gt;done&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;md5sum -c &quot;$file:r.checksum&quot; &amp;lt; &quot;$file&quot;&lt;&#x2F;code&gt; checks if the checksum of &lt;code&gt;$file&lt;&#x2F;code&gt; matches the checksum stored in &lt;code&gt;$file:r.checksum&lt;&#x2F;code&gt;. (&lt;a href=&quot;https:&#x2F;&#x2F;linux.die.net&#x2F;man&#x2F;1&#x2F;md5&quot;&gt;&lt;code&gt;md5&lt;&#x2F;code&gt; man page&lt;&#x2F;a&gt;)&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;$file:r&lt;&#x2F;code&gt; syntax in zsh removes the extension from the file path. (i.e. &lt;code&gt;illustrations&#x2F;array-diagram.tex&lt;&#x2F;code&gt; becomes &lt;code&gt;illustrations&#x2F;array-diagram&lt;&#x2F;code&gt;)&lt;sup&gt;&lt;a href=&quot;https:&#x2F;&#x2F;zaiste.net&#x2F;posts&#x2F;zsh-get-filename-extension-path&#x2F;&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h4 id=&quot;canceled-war-crime-four&quot;&gt;(Canceled) War crime Four&lt;a class=&quot;zola-anchor&quot; href=&quot;#canceled-war-crime-four&quot; aria-label=&quot;Anchor link for: canceled-war-crime-four&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;Next on my list was making sure that the code I wrote in my articles was well-tested and up-to-date. A bonus would be linking to the actual code file whenever I displayed a part of it in an article.&lt;&#x2F;p&gt;
&lt;p&gt;Zola has these things called shortcodes which can take parameters and insert HTML (for example &lt;code&gt;image (src=&quot;&quot;, caption=&quot;&quot;, ...)&lt;&#x2F;code&gt;) and call other special functions (such as &lt;code&gt;load_data()&lt;&#x2F;code&gt;, which loads in data from a file or URL)&lt;&#x2F;p&gt;
&lt;p&gt;I wanted to display relevant parts of my programs, so I needed to extract only those lines and display them. Unfortunately, Tera (the templating language Zola uses) was sorely not up to the task.&lt;&#x2F;p&gt;
&lt;p&gt;I got as far as properly extracting lines, but then I had to deal with removing extra indentation at the start of lines by a certain amount (i.e. delete &lt;em&gt;n&lt;&#x2F;em&gt; amount of tabs from the starting of each line.)&lt;&#x2F;p&gt;
&lt;p&gt;I gave up.&lt;&#x2F;p&gt;
&lt;p&gt;Instead, I built a web server in Python to serve file ranges and used something like &lt;code&gt;load_data​(url=​&quot;localhost:8000&#x2F;​?file=​illustrations;​start=5;​end=10&quot;)&lt;&#x2F;code&gt; to get code snippets.&lt;&#x2F;p&gt;
&lt;p&gt;Then I dropped that because:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;it felt &lt;em&gt;incredibly&lt;&#x2F;em&gt; ugly. Just think about it. To build your website, you must:
&lt;ul&gt;
&lt;li&gt;Run a script to build LaTeX files and then several sed invocations to get the svgs working.&lt;&#x2F;li&gt;
&lt;li&gt;Launch a Python server to properly cut and serve code blocks.&lt;&#x2F;li&gt;
&lt;li&gt;Run the actual site generator.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;it was likely that the caching zola did for URLs would interfere.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Could I have solved this problem? Yes. Did I want to? No, not really; the solution did not seem to warrant the cost. I settled for copy-pasting relevant code in articles. I&#x27;ll probably do something about that in the future once it becomes enough of a problem.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;bonus-problems&quot;&gt;Bonus problems&lt;a class=&quot;zola-anchor&quot; href=&quot;#bonus-problems&quot; aria-label=&quot;Anchor link for: bonus-problems&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;(Solved) Generating social preview images (in compliance with the &lt;a href=&quot;https:&#x2F;&#x2F;ogp.me&#x2F;&quot;&gt;Open Graph Protocol&lt;&#x2F;a&gt;) required me to also use ImageMagick and &lt;code&gt;pdflatex&lt;&#x2F;code&gt;, since &lt;code&gt;dvipngm&lt;&#x2F;code&gt; did &lt;em&gt;not&lt;&#x2F;em&gt; work because of some Tikz problems.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;(Unsolved) Using a custom domain. The domain I had was bought from an incredibly unknown provider with a website that looked like it was straight from the 2000s. I still don&#x27;t know why even after updating my DNS records that domain doesn&#x27;t redirect.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;(Solved) CSS. Everything new I tried - having line numbers in code blocks, getting code blocks to switch colors, etc. I had to adjust CSS every time.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;Writing this article does give me ideas for more improvements to my build process.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Integrating a spell-checker&lt;&#x2F;li&gt;
&lt;li&gt;Code snipping with line numbers and reference to the actual file &lt;em&gt;in&lt;&#x2F;em&gt; the codeblock itself.&lt;&#x2F;li&gt;
&lt;li&gt;Getting a custom domain&lt;&#x2F;li&gt;
&lt;li&gt;Automating social media preview generation instead of having to manually adjust the coordinates for ImageMagick to make a photo from the pdf made from a TeX file.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Update from the future (2022-6-9): I&#x27;m using &lt;code&gt;aspell&lt;&#x2F;code&gt; for spell-checking for now.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Update from the future-future (2022-12-30): I have a custom domain now. The domain wasn&#x27;t redirecting because it had the wrong NS servers.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Update from the futre-future-future (2023-1-21): I&#x27;m now custom building fonts from &lt;a href=&quot;https:&#x2F;&#x2F;fonts.google.com&#x2F;&quot;&gt;Google Fonts&lt;&#x2F;a&gt; through &lt;a href=&quot;https:&#x2F;&#x2F;fontforge.org&#x2F;en-US&#x2F;&quot;&gt;FontForge&lt;&#x2F;a&gt;. For some reason, &lt;code&gt;ttf&lt;&#x2F;code&gt; isn&#x27;t really working for me, so I&#x27;m converting fonts to &lt;code&gt;woff2&lt;&#x2F;code&gt; instead.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;retrospective&quot;&gt;Retrospective&lt;a class=&quot;zola-anchor&quot; href=&quot;#retrospective&quot; aria-label=&quot;Anchor link for: retrospective&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;I probably should have taken a step back from integrating LaTeX for diagrams and evaluated other tools. I only remembered recently that &lt;a href=&quot;https:&#x2F;&#x2F;plantuml.com&#x2F;&quot;&gt;PlantUML&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;mermaid-js.github.io&#x2F;mermaid&#x2F;#&#x2F;&quot;&gt;Mermaid&lt;&#x2F;a&gt; and many others existed.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;further-reading-references-footnotes&quot;&gt;Further Reading&#x2F;References&#x2F;Footnotes&lt;a class=&quot;zola-anchor&quot; href=&quot;#further-reading-references-footnotes&quot; aria-label=&quot;Anchor link for: further-reading-references-footnotes&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;While I would&#x27;ve loved to explain a lot of these on my own, unfortunately I lack the expertise necessary to speak much on these topics.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>(Basic) Segment Trees</title>
        <published>2022-01-18T00:00:00+00:00</published>
        <updated>2022-01-18T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.vashishtha.in/competitive-programming/dsa-explanations/basic-segment-tree/"/>
        <id>https://blog.vashishtha.in/competitive-programming/dsa-explanations/basic-segment-tree/</id>
        
        <content type="html" xml:base="https://blog.vashishtha.in/competitive-programming/dsa-explanations/basic-segment-tree/">&lt;h1 id=&quot;problem-introduction&quot;&gt;Problem Introduction&lt;a class=&quot;zola-anchor&quot; href=&quot;#problem-introduction&quot; aria-label=&quot;Anchor link for: problem-introduction&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Given an array of length $N$, we want to:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Query the maximum value of a range $[l, r]$&lt;&#x2F;li&gt;
&lt;li&gt;Change a particular index&#x27;s value&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;For example, we want to be able to:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Query the minimum value in the array in the range $[1, 3]$&lt;&#x2F;li&gt;
&lt;li&gt;Then change the value of the second element (&lt;code&gt;arr[2]&lt;&#x2F;code&gt;) to 5&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;... and repeat that &lt;em&gt;many&lt;&#x2F;em&gt; times.&lt;&#x2F;p&gt;
&lt;p&gt;Possible approaches:&lt;&#x2F;p&gt;
&lt;!-- Not applicable to maximum problem, only sum problem
- We could use [Prefix Sums](https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Prefix_sum) - this gives us $O(1)$ query time 
(`ans = arr[r] - arr[l - 1]`), but every time we update an element, we&#x27;ll have to reconstruct the array again, taking $O(N)$ time.
--&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;We could maintain the array as is - query time will be $O(N)$, but we can update in $O(1)$ time.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;We could break the array into blocks of arbitrary length, say $k$, and maintain maximums for each of them; we will get $O(\frac{N}{k})$ query time (as we query up to $N&#x2F;k$ blocks and $N \mod k$ individual elements) and $O(1)$ update time (as we only need to update the particular element and the whole block&#x27;s maximum). &lt;small&gt;This is the basic idea for a class of algorithms called square-root algorithms.&lt;&#x2F;small&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Use memoization to speed up queries. (We could even apply a bit of reasoning to drastically reduce the amount of queries we have to calculate; read &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Range_minimum_query#Solution_using_constant_time_and_linear_space&quot;&gt;here&lt;&#x2F;a&gt; for more on that.) This gives us $O(1)$ query time, but we still have to update the array in $O(N)$ time.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Some data structures made for efficient max range queries need to be rebuilt every time the array changes, while breaking the array into blocks of arbitrary length generally gets us about $O(\sqrt{N})$ update time, which is good, but we can do better.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;small&gt;
Oh, and maybe I should use some of &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Big_O_notation#Related_asymptotic_notations&quot;&gt;Big O&#x27;s siblings&lt;&#x2F;a&gt; as well to mess with people.
&lt;&#x2F;small&gt;
&lt;h1 id=&quot;segment-tree-with-2n-elements&quot;&gt;Segment Tree with 2&lt;sup&gt;n&lt;&#x2F;sup&gt; elements&lt;a class=&quot;zola-anchor&quot; href=&quot;#segment-tree-with-2n-elements&quot; aria-label=&quot;Anchor link for: segment-tree-with-2n-elements&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;small&gt;We will assume that the number of elements in the array is a power of 2 for now, as it makes it easier to explain. Don&#x27;t worry, we&#x27;ll talk about the general case in another article.&lt;&#x2F;small&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Some of what we talked about as a possible approach (i.e. memoization and splitting queries) is a useful idea. &lt;strong&gt;We can decompose a query into smaller parts, calculate and store their answer, then when responding to a query, we can piece the answer together by stitching together ranges. When we have to update an element, we only need to update the answer for ranges that &lt;em&gt;include&lt;&#x2F;em&gt; the element, and none of the others.&lt;&#x2F;strong&gt; This is the main idea which underlies most query data structures.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;The difference between Segment Trees, Square-Root Algorithms, and Sparse Tables is the way they split up ranges, which influences their time and memory complexity.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h3 id=&quot;concept&quot;&gt;Concept&lt;a class=&quot;zola-anchor&quot; href=&quot;#concept&quot; aria-label=&quot;Anchor link for: concept&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;Let us define an example array now to make things easier.&lt;&#x2F;p&gt;


&lt;figure class=&quot;center size-large&quot;&gt;&lt;!--Add proper accessibility to svgs: https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;4756461&#x2F;10147642 - if you&#x27;re reading this in DevTools, and have an idea of how to, feel free to write to me!--&gt;
	
	&lt;?xml version=&#x27;1.0&#x27; encoding=&#x27;UTF-8&#x27;?&gt;
&lt;!-- This file was generated by dvisvgm 3.2.2 --&gt;
&lt;svg version=&#x27;1.1&#x27; xmlns=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;2000&#x2F;svg&#x27; xmlns:xlink=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xlink&#x27;   viewBox=&#x27;154.429651 2.995859 159.140599 31.511983&#x27;&gt;
&lt;style type=&#x27;text&#x2F;css&#x27;&gt;
&lt;![CDATA[@font-face{font-family:cmr10;src:url(data:application&#x2F;x-font-ttf;base64,AAEAAAAKAIAAAwAgT1MvMoVMdCsAAACsAAAAYGNtYXAADACLAAABDAAAADRnbHlmYW8a1QAAAUAAAASoaGVhZCftHj8AAAXoAAAANmhoZWEFEAGSAAAGIAAAACRobXR4BSYA8gAABkQAAAAWbG9jYQRMBYQAAAZcAAAAFG1heHAADQA&#x2F;AAAGcAAAACBuYW1lguMqqQAABpAAAAE4cG9zdAADAAEAAAfIAAAAIAADAg4BkAAFAAACmgLN&#x2F;hQAjwKaAs0B7AHsADMBCQAAAAAGAAAAAAAAAAAAAAEAAAAAAAAAAAAAAABkc3ZnAAYAMQA4AwD&#x2F;AAAAAwABAAAAAAEAAAAAAAAAAAAA&#x2F;&#x2F;8AAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAIAAAAAQABAABAAAAOP&#x2F;&#x2F;AAAAMf&#x2F;&#x2F;&#x2F;9AAAQAAAAAAAQBbAAABrQKrABgAAAERBhY7ARUnIwc1MzI2JxEOASc1FjY3NhYBLQMgQiFRqlEhQx8DKUwRHGwzEQcCj&#x2F;3CHBUgAwMgFRwCEhMIAR8CFS8BCgAAAQAzAAABzQKqACsAADczNzY3Nj8BMwchNzY&#x2F;AT4BNzQmJyIGBzceARUOAScGJic+ATceARcWBwYHgrg3IgkHBgkaHf6EAQIIxSw&#x2F;AURGLUoTDRscAiUPBS4DAWdYX3gCATM2dU8BAQYNGzOyGAcH2zB1PUJjAjYyAQEgFB8ZAQITKUdvAwFtWUg+P2YAAAAAAQAr&#x2F;+kB1AKpADcAAAEeARcOAQcuASc+ARcyFhQGJx4CNjc0JicjBjYXNxY+AicuAQcmBgc2FhcUBiMmJz4BMh4BBgEpUVkBAnlfVncCASUTGCEnHB5cSEsDOz4tGgMNKBQwKwoBAj4iHlEZDi8CHBgwBAJknG0BTgFoEWdBUXIDAVlHIhsBHjkeAywjAUVmTVwBAxwBAwESSEUMQzABARslAhAlFx4BNTtPTX1hAAACAB0AAAHiArgAGgAdAAAlITUBNhcyFgcRMxUjFQYWOwEVJyMHNTMyNic3EQMBLf7wAToJDAwFAWZmAhk3FUWMRBU3GQIG+qkgAeAPAwsP&#x2F;i4gWRwUIAMDIBQceQF+&#x2F;oIAAAAAAQAz&#x2F;+kBzAKqAD0AACUOAQcuASc+ARceARQGByInHgEXNjc+ASc2Jy4BJw4BBwYjIjcRJjM2FxY3PgE&#x2F;ARYVFA8BBgcmJxU2Fx4BAcwDgFxXYgECJAwaGhoaDgMOUDhIJhEJAQMWBikoPT8IBAkSAwINAgpKPjRIDwkKLBAzVzQjOEpVbM5kfgMEckYjFAEBHiYeAQIvQwEDQCFOHUs2EDACBDUPCRoBLxkBBB8CARUIAwEKDicMJgQCDMg1AQN&#x2F;AAAAAAIAK&#x2F;&#x2F;mAdQCqgAoADwAABM+ATceARcOAQcGJyYnJic2PwE2Nx4BFQ4BLgEnPgEXLgEHJgcGBwYHExY2Nz4BNCYnLgEHDgEXBhYXHgGHEDw0V3QCAnlYQz4ODTcDBE0JUGNAQgEgHx0BAikNEjQUITQYFywDehI7GA0GBg4ZOQ1EOgEBBg4EMQFQJzwCAn9jaH0DAzsOE021pF4MVwEBPy8dFQEYFyEOARoQAQMfEyI&#x2F;mP6eAhksHEhLShwuFAIEc0AQXScPOwAAAQA5&#x2F;+kB8QK0ACEAAAEHDgEHBh0BFgYHLgE3JjY&#x2F;AgUGBwYPASM3MwYWOwEHBgHniiEcAgwBDiIhDwEBO0RIK&#x2F;74JwkLBgkaIhoBKlr5AQICcMMyaRRTVTQKLAMDLApQx2plPQEBBQwhMNMOExUGAAMAK&#x2F;&#x2F;pAdUCqgALACkANQAAExc+ATcuASIGBwYWHwEWFx4BBw4BBy4BJz4BNycmJy4BNz4BNx4BFw4BBw4BFx4BMjY3LgEnp38vNQECUXFRAgESt0QUDhwXAQJ6WVR9AwRfMCsWCR8PAQJoT0lsAwFCn0A5AQJchl0CAjMYAdRSG0gsOUU5Lw0ueSwPDiFBHFRsAwFfUktcFR4PCiU+DklgAgFQSDNPRyVbLUJSRzkuNA8AAAEAAAABAABlRLQVXw889QADBAAAAAAA4yrtUgAAAADjKu1SAAD&#x2F;5gKAArgAAAAIAAIAAAAAAAAAAQAAAwD&#x2F;AAAAAoAAHQAPAfEAAQAAAAAAAAAAAAAAAAAAAAICgAAAAgAAWwAzACsAHQAzACsAOQArAAAAAAAAACoAcgDKAPwBXgHCAfoCVAABAAAACQA+AAMAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgB+AAEAAAAAAAEADwAAAAEAAAAAAAQABQAPAAEAAAAAAAUACwAUAAEAAAAAAAYABQAfAAEAAAAAAAoAGgAkAAMAAQQJAAEAHgA+AAMAAQQJAAQACgBcAAMAAQQJAAUAFgBmAAMAAQQJAAYACgB8AAMAAQQJAAoANACGQ29tcHV0ZXIgTW9kZXJuY21yMTBWZXJzaW9uIDEuMGNtcjEwR2VuZXJhdGVkIGJ5IGR2aXN2Z20gMy4yLjIAQwBvAG0AcAB1AHQAZQByACAATQBvAGQAZQByAG4AYwBtAHIAMQAwAFYAZQByAHMAaQBvAG4AIAAxAC4AMABjAG0AcgAxADAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABkAHYAaQBzAHYAZwBtACAAMwAuADIALgAyAAMAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=) format(&#x27;truetype&#x27;);}
text.f0 {font-family:cmr10;font-size:9.96264px}
]]&gt;
&lt;&#x2F;style&gt;
&lt;g id=&#x27;page1&#x27;&gt;
&lt;path d=&#x27;M154.628901 34.308592H313.371M154.628901 14.4727H313.371M154.628901 34.308592V14.4687M174.4727 34.308592V14.4687M194.3164 34.308592V14.4687M214.1562 34.308592V14.4687M234 34.308592V14.4687M253.8437 34.308592V14.4687M273.687 34.308592V14.4687M293.527 34.308592V14.4687M313.363 34.308592V14.4687&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 7.431 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 7.431 -24.5694)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 27.273 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 27.273 -24.5694)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 47.116 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 47.116 -24.5694)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 66.959 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 66.959 -24.5694)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 86.801 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 86.801 -24.5694)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 106.644 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 106.644 -24.5694)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;6&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 126.487 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 126.487 -24.5694)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;7&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 146.329 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;34.309967&#x27; transform=&#x27;matrix(1 0 0 1 146.329 -24.5694)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;svg&gt;

	
		&lt;figcaption  style=&quot;font-style: italic;&quot;&gt;Example array&lt;&#x2F;figcaption&gt;
	

&lt;&#x2F;figure&gt;
&lt;p&gt;We start with the case of needing to find the maximum of a single index, e.g. $[2, 2]$ in which case, we already know that it&#x27;s going to be &lt;code&gt;arr[2]&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Next, $[1, 2]$. We observe:&lt;&#x2F;p&gt;
&lt;p&gt;$$[1, 2] = \max{([1, 1], [2, 2])}$$ &lt;!-- \max{([1, 2], [3, 4], [5], [6])} = \max{([1], [2], [3], [4], [5], [6])} --&gt;&lt;&#x2F;p&gt;


&lt;figure class=&quot;center size-medium&quot;&gt;&lt;!--Add proper accessibility to svgs: https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;4756461&#x2F;10147642 - if you&#x27;re reading this in DevTools, and have an idea of how to, feel free to write to me!--&gt;
	
	&lt;?xml version=&#x27;1.0&#x27; encoding=&#x27;UTF-8&#x27;?&gt;
&lt;!-- This file was generated by dvisvgm 3.2.2 --&gt;
&lt;svg version=&#x27;1.1&#x27; xmlns=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;2000&#x2F;svg&#x27; xmlns:xlink=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xlink&#x27;   viewBox=&#x27;154.429651 -.00005 159.140599 58.757895&#x27;&gt;
&lt;style type=&#x27;text&#x2F;css&#x27;&gt;
&lt;![CDATA[@font-face{font-family:cmr10;src:url(data:application&#x2F;x-font-ttf;base64,AAEAAAAKAIAAAwAgT1MvMoVMdCsAAACsAAAAYGNtYXAADACLAAABDAAAADRnbHlmYW8a1QAAAUAAAASoaGVhZCftHkEAAAXoAAAANmhoZWEFEAGSAAAGIAAAACRobXR4BSYA8gAABkQAAAAWbG9jYQRMBYQAAAZcAAAAFG1heHAADQA&#x2F;AAAGcAAAACBuYW1lguMqqQAABpAAAAE4cG9zdAADAAEAAAfIAAAAIAADAg4BkAAFAAACmgLN&#x2F;hQAjwKaAs0B7AHsADMBCQAAAAAGAAAAAAAAAAAAAAEAAAAAAAAAAAAAAABkc3ZnAAYAMQA4AwD&#x2F;AAAAAwABAAAAAAEAAAAAAAAAAAAA&#x2F;&#x2F;8AAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAIAAAAAQABAABAAAAOP&#x2F;&#x2F;AAAAMf&#x2F;&#x2F;&#x2F;9AAAQAAAAAAAQBbAAABrQKrABgAAAERBhY7ARUnIwc1MzI2JxEOASc1FjY3NhYBLQMgQiFRqlEhQx8DKUwRHGwzEQcCj&#x2F;3CHBUgAwMgFRwCEhMIAR8CFS8BCgAAAQAzAAABzQKqACsAADczNzY3Nj8BMwchNzY&#x2F;AT4BNzQmJyIGBzceARUOAScGJic+ATceARcWBwYHgrg3IgkHBgkaHf6EAQIIxSw&#x2F;AURGLUoTDRscAiUPBS4DAWdYX3gCATM2dU8BAQYNGzOyGAcH2zB1PUJjAjYyAQEgFB8ZAQITKUdvAwFtWUg+P2YAAAAAAQAr&#x2F;+kB1AKpADcAAAEeARcOAQcuASc+ARcyFhQGJx4CNjc0JicjBjYXNxY+AicuAQcmBgc2FhcUBiMmJz4BMh4BBgEpUVkBAnlfVncCASUTGCEnHB5cSEsDOz4tGgMNKBQwKwoBAj4iHlEZDi8CHBgwBAJknG0BTgFoEWdBUXIDAVlHIhsBHjkeAywjAUVmTVwBAxwBAwESSEUMQzABARslAhAlFx4BNTtPTX1hAAACAB0AAAHiArgAGgAdAAAlITUBNhcyFgcRMxUjFQYWOwEVJyMHNTMyNic3EQMBLf7wAToJDAwFAWZmAhk3FUWMRBU3GQIG+qkgAeAPAwsP&#x2F;i4gWRwUIAMDIBQceQF+&#x2F;oIAAAAAAQAz&#x2F;+kBzAKqAD0AACUOAQcuASc+ARceARQGByInHgEXNjc+ASc2Jy4BJw4BBwYjIjcRJjM2FxY3PgE&#x2F;ARYVFA8BBgcmJxU2Fx4BAcwDgFxXYgECJAwaGhoaDgMOUDhIJhEJAQMWBikoPT8IBAkSAwINAgpKPjRIDwkKLBAzVzQjOEpVbM5kfgMEckYjFAEBHiYeAQIvQwEDQCFOHUs2EDACBDUPCRoBLxkBBB8CARUIAwEKDicMJgQCDMg1AQN&#x2F;AAAAAAIAK&#x2F;&#x2F;mAdQCqgAoADwAABM+ATceARcOAQcGJyYnJic2PwE2Nx4BFQ4BLgEnPgEXLgEHJgcGBwYHExY2Nz4BNCYnLgEHDgEXBhYXHgGHEDw0V3QCAnlYQz4ODTcDBE0JUGNAQgEgHx0BAikNEjQUITQYFywDehI7GA0GBg4ZOQ1EOgEBBg4EMQFQJzwCAn9jaH0DAzsOE021pF4MVwEBPy8dFQEYFyEOARoQAQMfEyI&#x2F;mP6eAhksHEhLShwuFAIEc0AQXScPOwAAAQA5&#x2F;+kB8QK0ACEAAAEHDgEHBh0BFgYHLgE3JjY&#x2F;AgUGBwYPASM3MwYWOwEHBgHniiEcAgwBDiIhDwEBO0RIK&#x2F;74JwkLBgkaIhoBKlr5AQICcMMyaRRTVTQKLAMDLApQx2plPQEBBQwhMNMOExUGAAMAK&#x2F;&#x2F;pAdUCqgALACkANQAAExc+ATcuASIGBwYWHwEWFx4BBw4BBy4BJz4BNycmJy4BNz4BNx4BFw4BBw4BFx4BMjY3LgEnp38vNQECUXFRAgESt0QUDhwXAQJ6WVR9AwRfMCsWCR8PAQJoT0lsAwFCn0A5AQJchl0CAjMYAdRSG0gsOUU5Lw0ueSwPDiFBHFRsAwFfUktcFR4PCiU+DklgAgFQSDNPRyVbLUJSRzkuNA8AAAEAAAABAABlRLQRXw889QADBAAAAAAA4yrtUwAAAADjKu1TAAD&#x2F;5gKAArgAAAAIAAIAAAAAAAAAAQAAAwD&#x2F;AAAAAoAAHQAPAfEAAQAAAAAAAAAAAAAAAAAAAAICgAAAAgAAWwAzACsAHQAzACsAOQArAAAAAAAAACoAcgDKAPwBXgHCAfoCVAABAAAACQA+AAMAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgB+AAEAAAAAAAEADwAAAAEAAAAAAAQABQAPAAEAAAAAAAUACwAUAAEAAAAAAAYABQAfAAEAAAAAAAoAGgAkAAMAAQQJAAEAHgA+AAMAAQQJAAQACgBcAAMAAQQJAAUAFgBmAAMAAQQJAAYACgB8AAMAAQQJAAoANACGQ29tcHV0ZXIgTW9kZXJuY21yMTBWZXJzaW9uIDEuMGNtcjEwR2VuZXJhdGVkIGJ5IGR2aXN2Z20gMy4yLjIAQwBvAG0AcAB1AHQAZQByACAATQBvAGQAZQByAG4AYwBtAHIAMQAwAFYAZQByAHMAaQBvAG4AIAAxAC4AMABjAG0AcgAxADAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABkAHYAaQBzAHYAZwBtACAAMwAuADIALgAyAAMAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=) format(&#x27;truetype&#x27;);}
text.f0 {font-family:cmr10;font-size:9.96264px}
]]&gt;
&lt;&#x2F;style&gt;
&lt;g id=&#x27;page1&#x27;&gt;
&lt;path d=&#x27;M154.628901 58.558595V38.7148H194.3164V58.558595Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M154.628901 58.558595H313.371M154.628901 38.7227H313.371M154.628901 58.558595V38.7148M174.4727 58.558595V38.7148M194.3164 58.558595V38.7148M214.1562 58.558595V38.7148M234 58.558595V38.7148M253.8437 58.558595V38.7148M273.687 58.558595V38.7148M293.527 58.558595V38.7148M313.363 58.558595V38.7148&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 7.431 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 27.273 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 47.116 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 66.959 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 86.801 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 106.644 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 126.487 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 146.329 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M183.2266 8.9531C183.2266 4.1172 179.3086 .1992 174.4727 .1992C169.6367 .1992 165.7187 4.1172 165.7187 8.9531C165.7187 13.7852 169.6367 17.7031 174.4727 17.7031C179.3086 17.7031 183.2266 13.7852 183.2266 8.9531Z&#x27; fill=&#x27;var(--diagram-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M183.2266 8.9531C183.2266 4.1172 179.3086 .1992 174.4727 .1992C169.6367 .1992 165.7187 4.1172 165.7187 8.9531C165.7187 13.7852 169.6367 17.7031 174.4727 17.7031C179.3086 17.7031 183.2266 13.7852 183.2266 8.9531Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 17.352 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M171.6406 17.4453L164.55078 38.7148&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M177.3047 17.4453L184.3945 38.7148&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 8.9531C222.9102 4.1172 218.9922 .1992 214.1562 .1992C209.3242 .1992 205.4062 4.1172 205.4062 8.9531C205.4062 13.7852 209.3242 17.7031 214.1562 17.7031C218.9922 17.7031 222.9102 13.7852 222.9102 8.9531Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 57.037 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M211.3281 17.4453L204.2383 38.7148&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M216.9883 17.4453L224.0781 38.7148&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.598 8.9531C262.598 4.1172 258.676 .1992 253.8437 .1992C249.0078 .1992 245.0898 4.1172 245.0898 8.9531C245.0898 13.7852 249.0078 17.7031 253.8437 17.7031C258.676 17.7031 262.598 13.7852 262.598 8.9531Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 96.723 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M251.0156 17.4453L243.9219 38.7148&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M256.676 17.4453L263.766 38.7148&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M302.281 8.9531C302.281 4.1172 298.363 .1992 293.527 .1992C288.695 .1992 284.777 4.1172 284.777 8.9531C284.777 13.7852 288.695 17.7031 293.527 17.7031C298.363 17.7031 302.281 13.7852 302.281 8.9531Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(1 0 0 1 136.408 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M290.699 17.4453L283.609 38.7148&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M296.363 17.4453L303.449 38.7148&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M169.3672 37.7227C169.3672 35.0664 167.2109 32.9102 164.55078 32.9102C161.89062 32.9102 159.73828 35.0664 159.73828 37.7227C159.73828 40.3828 161.89062 42.5391 164.55078 42.5391C167.2109 42.5391 169.3672 40.3828 169.3672 37.7227Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M169.3672 37.7227C169.3672 35.0664 167.2109 32.9102 164.55078 32.9102C161.89062 32.9102 159.73828 35.0664 159.73828 37.7227C159.73828 40.3828 161.89062 42.5391 164.55078 42.5391C167.2109 42.5391 169.3672 40.3828 169.3672 37.7227Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(.55 0 0 .55 78.1345 7.28208)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M189.207 37.7227C189.207 35.0664 187.0547 32.9102 184.3945 32.9102C181.7344 32.9102 179.5781 35.0664 179.5781 37.7227C179.5781 40.3828 181.7344 42.5391 184.3945 42.5391C187.0547 42.5391 189.207 40.3828 189.207 37.7227Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M189.207 37.7227C189.207 35.0664 187.0547 32.9102 184.3945 32.9102C181.7344 32.9102 179.5781 35.0664 179.5781 37.7227C179.5781 40.3828 181.7344 42.5391 184.3945 42.5391C187.0547 42.5391 189.207 40.3828 189.207 37.7227Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(.55 0 0 .55 97.9775 7.28208)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M209.0508 37.7227C209.0508 35.0664 206.8945 32.9102 204.2383 32.9102C201.5781 32.9102 199.4219 35.0664 199.4219 37.7227C199.4219 40.3828 201.5781 42.5391 204.2383 42.5391C206.8945 42.5391 209.0508 40.3828 209.0508 37.7227Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M209.0508 37.7227C209.0508 35.0664 206.8945 32.9102 204.2383 32.9102C201.5781 32.9102 199.4219 35.0664 199.4219 37.7227C199.4219 40.3828 201.5781 42.5391 204.2383 42.5391C206.8945 42.5391 209.0508 40.3828 209.0508 37.7227Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(.55 0 0 .55 117.8205 7.28208)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M228.8945 37.7227C228.8945 35.0664 226.7383 32.9102 224.0781 32.9102C221.4219 32.9102 219.2656 35.0664 219.2656 37.7227C219.2656 40.3828 221.4219 42.5391 224.0781 42.5391C226.7383 42.5391 228.8945 40.3828 228.8945 37.7227Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M228.8945 37.7227C228.8945 35.0664 226.7383 32.9102 224.0781 32.9102C221.4219 32.9102 219.2656 35.0664 219.2656 37.7227C219.2656 40.3828 221.4219 42.5391 224.0781 42.5391C226.7383 42.5391 228.8945 40.3828 228.8945 37.7227Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(.55 0 0 .55 137.6625 7.28208)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M248.7344 37.7227C248.7344 35.0664 246.582 32.9102 243.9219 32.9102C241.2617 32.9102 239.1094 35.0664 239.1094 37.7227C239.1094 40.3828 241.2617 42.5391 243.9219 42.5391C246.582 42.5391 248.7344 40.3828 248.7344 37.7227Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M248.7344 37.7227C248.7344 35.0664 246.582 32.9102 243.9219 32.9102C241.2617 32.9102 239.1094 35.0664 239.1094 37.7227C239.1094 40.3828 241.2617 42.5391 243.9219 42.5391C246.582 42.5391 248.7344 40.3828 248.7344 37.7227Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(.55 0 0 .55 157.5055 7.28208)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M268.578 37.7227C268.578 35.0664 266.422 32.9102 263.766 32.9102C261.105 32.9102 258.949 35.0664 258.949 37.7227C258.949 40.3828 261.105 42.5391 263.766 42.5391C266.422 42.5391 268.578 40.3828 268.578 37.7227Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M268.578 37.7227C268.578 35.0664 266.422 32.9102 263.766 32.9102C261.105 32.9102 258.949 35.0664 258.949 37.7227C258.949 40.3828 261.105 42.5391 263.766 42.5391C266.422 42.5391 268.578 40.3828 268.578 37.7227Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(.55 0 0 .55 177.3485 7.28208)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;6&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M288.422 37.7227C288.422 35.0664 286.266 32.9102 283.609 32.9102C280.949 32.9102 278.793 35.0664 278.793 37.7227C278.793 40.3828 280.949 42.5391 283.609 42.5391C286.266 42.5391 288.422 40.3828 288.422 37.7227Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M288.422 37.7227C288.422 35.0664 286.266 32.9102 283.609 32.9102C280.949 32.9102 278.793 35.0664 278.793 37.7227C278.793 40.3828 280.949 42.5391 283.609 42.5391C286.266 42.5391 288.422 40.3828 288.422 37.7227Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(.55 0 0 .55 197.1915 7.28208)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;7&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M308.266 37.7227C308.266 35.0664 306.109 32.9102 303.449 32.9102C300.793 32.9102 298.637 35.0664 298.637 37.7227C298.637 40.3828 300.793 42.5391 303.449 42.5391C306.109 42.5391 308.266 40.3828 308.266 37.7227Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M308.266 37.7227C308.266 35.0664 306.109 32.9102 303.449 32.9102C300.793 32.9102 298.637 35.0664 298.637 37.7227C298.637 40.3828 300.793 42.5391 303.449 42.5391C306.109 42.5391 308.266 40.3828 308.266 37.7227Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;58.55836&#x27; transform=&#x27;matrix(.55 0 0 .55 217.0335 7.28208)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;svg&gt;

	
		&lt;figcaption  style=&quot;font-style: italic;&quot;&gt;Partial Segment Tree&lt;&#x2F;figcaption&gt;
	

&lt;&#x2F;figure&gt;
&lt;blockquote&gt;
&lt;p&gt;The division in ranges that defines segment trees is dividing ranges in &lt;em&gt;half&lt;&#x2F;em&gt;. It&#x27;s a quite elegant idea really - we group two indices, then group two of those, and so on...&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;What about $[1, 6]$?&lt;&#x2F;p&gt;


&lt;figure class=&quot;center size-smallish&quot;&gt;&lt;!--Add proper accessibility to svgs: https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;4756461&#x2F;10147642 - if you&#x27;re reading this in DevTools, and have an idea of how to, feel free to write to me!--&gt;
	
	&lt;?xml version=&#x27;1.0&#x27; encoding=&#x27;UTF-8&#x27;?&gt;
&lt;!-- This file was generated by dvisvgm 3.2.2 --&gt;
&lt;svg version=&#x27;1.1&#x27; xmlns=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;2000&#x2F;svg&#x27; xmlns:xlink=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xlink&#x27;   viewBox=&#x27;154.429651 -.00005 159.140599 90.273517&#x27;&gt;
&lt;style type=&#x27;text&#x2F;css&#x27;&gt;
&lt;![CDATA[@font-face{font-family:cmr10;src:url(data:application&#x2F;x-font-ttf;base64,AAEAAAAKAIAAAwAgT1MvMoVMdCsAAACsAAAAYGNtYXAADACLAAABDAAAADRnbHlmYW8a1QAAAUAAAASoaGVhZCftHkEAAAXoAAAANmhoZWEFEAGSAAAGIAAAACRobXR4BSYA8gAABkQAAAAWbG9jYQRMBYQAAAZcAAAAFG1heHAADQA&#x2F;AAAGcAAAACBuYW1lguMqqQAABpAAAAE4cG9zdAADAAEAAAfIAAAAIAADAg4BkAAFAAACmgLN&#x2F;hQAjwKaAs0B7AHsADMBCQAAAAAGAAAAAAAAAAAAAAEAAAAAAAAAAAAAAABkc3ZnAAYAMQA4AwD&#x2F;AAAAAwABAAAAAAEAAAAAAAAAAAAA&#x2F;&#x2F;8AAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAIAAAAAQABAABAAAAOP&#x2F;&#x2F;AAAAMf&#x2F;&#x2F;&#x2F;9AAAQAAAAAAAQBbAAABrQKrABgAAAERBhY7ARUnIwc1MzI2JxEOASc1FjY3NhYBLQMgQiFRqlEhQx8DKUwRHGwzEQcCj&#x2F;3CHBUgAwMgFRwCEhMIAR8CFS8BCgAAAQAzAAABzQKqACsAADczNzY3Nj8BMwchNzY&#x2F;AT4BNzQmJyIGBzceARUOAScGJic+ATceARcWBwYHgrg3IgkHBgkaHf6EAQIIxSw&#x2F;AURGLUoTDRscAiUPBS4DAWdYX3gCATM2dU8BAQYNGzOyGAcH2zB1PUJjAjYyAQEgFB8ZAQITKUdvAwFtWUg+P2YAAAAAAQAr&#x2F;+kB1AKpADcAAAEeARcOAQcuASc+ARcyFhQGJx4CNjc0JicjBjYXNxY+AicuAQcmBgc2FhcUBiMmJz4BMh4BBgEpUVkBAnlfVncCASUTGCEnHB5cSEsDOz4tGgMNKBQwKwoBAj4iHlEZDi8CHBgwBAJknG0BTgFoEWdBUXIDAVlHIhsBHjkeAywjAUVmTVwBAxwBAwESSEUMQzABARslAhAlFx4BNTtPTX1hAAACAB0AAAHiArgAGgAdAAAlITUBNhcyFgcRMxUjFQYWOwEVJyMHNTMyNic3EQMBLf7wAToJDAwFAWZmAhk3FUWMRBU3GQIG+qkgAeAPAwsP&#x2F;i4gWRwUIAMDIBQceQF+&#x2F;oIAAAAAAQAz&#x2F;+kBzAKqAD0AACUOAQcuASc+ARceARQGByInHgEXNjc+ASc2Jy4BJw4BBwYjIjcRJjM2FxY3PgE&#x2F;ARYVFA8BBgcmJxU2Fx4BAcwDgFxXYgECJAwaGhoaDgMOUDhIJhEJAQMWBikoPT8IBAkSAwINAgpKPjRIDwkKLBAzVzQjOEpVbM5kfgMEckYjFAEBHiYeAQIvQwEDQCFOHUs2EDACBDUPCRoBLxkBBB8CARUIAwEKDicMJgQCDMg1AQN&#x2F;AAAAAAIAK&#x2F;&#x2F;mAdQCqgAoADwAABM+ATceARcOAQcGJyYnJic2PwE2Nx4BFQ4BLgEnPgEXLgEHJgcGBwYHExY2Nz4BNCYnLgEHDgEXBhYXHgGHEDw0V3QCAnlYQz4ODTcDBE0JUGNAQgEgHx0BAikNEjQUITQYFywDehI7GA0GBg4ZOQ1EOgEBBg4EMQFQJzwCAn9jaH0DAzsOE021pF4MVwEBPy8dFQEYFyEOARoQAQMfEyI&#x2F;mP6eAhksHEhLShwuFAIEc0AQXScPOwAAAQA5&#x2F;+kB8QK0ACEAAAEHDgEHBh0BFgYHLgE3JjY&#x2F;AgUGBwYPASM3MwYWOwEHBgHniiEcAgwBDiIhDwEBO0RIK&#x2F;74JwkLBgkaIhoBKlr5AQICcMMyaRRTVTQKLAMDLApQx2plPQEBBQwhMNMOExUGAAMAK&#x2F;&#x2F;pAdUCqgALACkANQAAExc+ATcuASIGBwYWHwEWFx4BBw4BBy4BJz4BNycmJy4BNz4BNx4BFw4BBw4BFx4BMjY3LgEnp38vNQECUXFRAgESt0QUDhwXAQJ6WVR9AwRfMCsWCR8PAQJoT0lsAwFCn0A5AQJchl0CAjMYAdRSG0gsOUU5Lw0ueSwPDiFBHFRsAwFfUktcFR4PCiU+DklgAgFQSDNPRyVbLUJSRzkuNA8AAAEAAAABAABlRLQRXw889QADBAAAAAAA4yrtUwAAAADjKu1TAAD&#x2F;5gKAArgAAAAIAAIAAAAAAAAAAQAAAwD&#x2F;AAAAAoAAHQAPAfEAAQAAAAAAAAAAAAAAAAAAAAICgAAAAgAAWwAzACsAHQAzACsAOQArAAAAAAAAACoAcgDKAPwBXgHCAfoCVAABAAAACQA+AAMAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgB+AAEAAAAAAAEADwAAAAEAAAAAAAQABQAPAAEAAAAAAAUACwAUAAEAAAAAAAYABQAfAAEAAAAAAAoAGgAkAAMAAQQJAAEAHgA+AAMAAQQJAAQACgBcAAMAAQQJAAUAFgBmAAMAAQQJAAYACgB8AAMAAQQJAAoANACGQ29tcHV0ZXIgTW9kZXJuY21yMTBWZXJzaW9uIDEuMGNtcjEwR2VuZXJhdGVkIGJ5IGR2aXN2Z20gMy4yLjIAQwBvAG0AcAB1AHQAZQByACAATQBvAGQAZQByAG4AYwBtAHIAMQAwAFYAZQByAHMAaQBvAG4AIAAxAC4AMABjAG0AcgAxADAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABkAHYAaQBzAHYAZwBtACAAMwAuADIALgAyAAMAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=) format(&#x27;truetype&#x27;);}
text.f0 {font-family:cmr10;font-size:9.96264px}
]]&gt;
&lt;&#x2F;style&gt;
&lt;g id=&#x27;page1&#x27;&gt;
&lt;path d=&#x27;M154.628901 90.074217V70.2305H273.687V90.074217Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M154.628901 90.074217H313.371M154.628901 70.2383H313.371M154.628901 90.074217V70.2305M174.4727 90.074217V70.2305M194.3164 90.074217V70.2305M214.1562 90.074217V70.2305M234 90.074217V70.2305M253.8437 90.074217V70.2305M273.687 90.074217V70.2305M293.527 90.074217V70.2305M313.363 90.074217V70.2305&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 7.431 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 27.273 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 47.116 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 66.959 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 86.801 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 106.644 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 126.487 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 146.329 -6.7111)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M183.2266 40.4648C183.2266 35.6328 179.3086 31.7109 174.4727 31.7109C169.6367 31.7109 165.7187 35.6328 165.7187 40.4648C165.7187 45.3008 169.6367 49.2187 174.4727 49.2187C179.3086 49.2187 183.2266 45.3008 183.2266 40.4648Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M183.2266 40.4648C183.2266 35.6328 179.3086 31.7109 174.4727 31.7109C169.6367 31.7109 165.7187 35.6328 165.7187 40.4648C165.7187 45.3008 169.6367 49.2187 174.4727 49.2187C179.3086 49.2187 183.2266 45.3008 183.2266 40.4648Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 17.352 -46.3964)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M171.6406 48.957L164.55078 70.2305&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M177.3047 48.957L184.3945 70.2305&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 40.4648C222.9102 35.6328 218.9922 31.7109 214.1562 31.7109C209.3242 31.7109 205.4062 35.6328 205.4062 40.4648C205.4062 45.3008 209.3242 49.2187 214.1562 49.2187C218.9922 49.2187 222.9102 45.3008 222.9102 40.4648Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 40.4648C222.9102 35.6328 218.9922 31.7109 214.1562 31.7109C209.3242 31.7109 205.4062 35.6328 205.4062 40.4648C205.4062 45.3008 209.3242 49.2187 214.1562 49.2187C218.9922 49.2187 222.9102 45.3008 222.9102 40.4648Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 57.037 -46.3964)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M211.3281 48.957L204.2383 70.2305&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M216.9883 48.957L224.0781 70.2305&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.598 40.4648C262.598 35.6328 258.676 31.7109 253.8437 31.7109C249.0078 31.7109 245.0898 35.6328 245.0898 40.4648C245.0898 45.3008 249.0078 49.2187 253.8437 49.2187C258.676 49.2187 262.598 45.3008 262.598 40.4648Z&#x27; fill=&#x27;var(--diagram-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.598 40.4648C262.598 35.6328 258.676 31.7109 253.8437 31.7109C249.0078 31.7109 245.0898 35.6328 245.0898 40.4648C245.0898 45.3008 249.0078 49.2187 253.8437 49.2187C258.676 49.2187 262.598 45.3008 262.598 40.4648Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 96.723 -46.3964)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M251.0156 48.957L243.9219 70.2305&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M256.676 48.957L263.766 70.2305&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M302.281 40.4648C302.281 35.6328 298.363 31.7109 293.527 31.7109C288.695 31.7109 284.777 35.6328 284.777 40.4648C284.777 45.3008 288.695 49.2187 293.527 49.2187C298.363 49.2187 302.281 45.3008 302.281 40.4648Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1 0 0 1 136.408 -46.3964)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M290.699 48.957L283.609 70.2305&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M296.363 48.957L303.449 70.2305&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M204.8203 10.7031C204.8203 4.9023 200.1172 .1992 194.3164 .1992S183.8125 4.9023 183.8125 10.7031S188.5156 21.207 194.3164 21.207S204.8203 16.5039 204.8203 10.7031Z&#x27; fill=&#x27;var(--diagram-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M204.8203 10.7031C204.8203 4.9023 200.1172 .1992 194.3164 .1992S183.8125 4.9023 183.8125 10.7031S188.5156 21.207 194.3164 21.207S204.8203 16.5039 204.8203 10.7031Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1.2 0 0 1.2 5.771 -93.53302)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.3555 19.6406L179.4375 33.0156&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M200.2773 19.6367L209.1953 33.0156&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M284.191 10.7031C284.191 4.9023 279.488 .1992 273.687 .1992C267.887 .1992 263.184 4.9023 263.184 10.7031S267.887 21.207 273.687 21.207C279.488 21.207 284.191 16.5039 284.191 10.7031Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(1.2 0 0 1.2 85.141 -93.53302)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M267.73 19.6406L258.812 33.0156&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M279.648 19.6367L288.566 33.0156&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M169.3672 69.2383C169.3672 66.5781 167.2109 64.4219 164.55078 64.4219C161.89062 64.4219 159.73828 66.5781 159.73828 69.2383C159.73828 71.8984 161.89062 74.0508 164.55078 74.0508C167.2109 74.0508 169.3672 71.8984 169.3672 69.2383Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M169.3672 69.2383C169.3672 66.5781 167.2109 64.4219 164.55078 64.4219C161.89062 64.4219 159.73828 66.5781 159.73828 69.2383C159.73828 71.8984 161.89062 74.0508 164.55078 74.0508C167.2109 74.0508 169.3672 71.8984 169.3672 69.2383Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(.55 0 0 .55 78.1345 21.46347)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M189.207 69.2383C189.207 66.5781 187.0547 64.4219 184.3945 64.4219C181.7344 64.4219 179.5781 66.5781 179.5781 69.2383C179.5781 71.8984 181.7344 74.0508 184.3945 74.0508C187.0547 74.0508 189.207 71.8984 189.207 69.2383Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M189.207 69.2383C189.207 66.5781 187.0547 64.4219 184.3945 64.4219C181.7344 64.4219 179.5781 66.5781 179.5781 69.2383C179.5781 71.8984 181.7344 74.0508 184.3945 74.0508C187.0547 74.0508 189.207 71.8984 189.207 69.2383Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(.55 0 0 .55 97.9775 21.46347)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M209.0508 69.2383C209.0508 66.5781 206.8945 64.4219 204.2383 64.4219C201.5781 64.4219 199.4219 66.5781 199.4219 69.2383C199.4219 71.8984 201.5781 74.0508 204.2383 74.0508C206.8945 74.0508 209.0508 71.8984 209.0508 69.2383Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M209.0508 69.2383C209.0508 66.5781 206.8945 64.4219 204.2383 64.4219C201.5781 64.4219 199.4219 66.5781 199.4219 69.2383C199.4219 71.8984 201.5781 74.0508 204.2383 74.0508C206.8945 74.0508 209.0508 71.8984 209.0508 69.2383Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(.55 0 0 .55 117.8205 21.46347)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M228.8945 69.2383C228.8945 66.5781 226.7383 64.4219 224.0781 64.4219C221.4219 64.4219 219.2656 66.5781 219.2656 69.2383C219.2656 71.8984 221.4219 74.0508 224.0781 74.0508C226.7383 74.0508 228.8945 71.8984 228.8945 69.2383Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M228.8945 69.2383C228.8945 66.5781 226.7383 64.4219 224.0781 64.4219C221.4219 64.4219 219.2656 66.5781 219.2656 69.2383C219.2656 71.8984 221.4219 74.0508 224.0781 74.0508C226.7383 74.0508 228.8945 71.8984 228.8945 69.2383Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(.55 0 0 .55 137.6625 21.46347)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M248.7344 69.2383C248.7344 66.5781 246.582 64.4219 243.9219 64.4219C241.2617 64.4219 239.1094 66.5781 239.1094 69.2383C239.1094 71.8984 241.2617 74.0508 243.9219 74.0508C246.582 74.0508 248.7344 71.8984 248.7344 69.2383Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M248.7344 69.2383C248.7344 66.5781 246.582 64.4219 243.9219 64.4219C241.2617 64.4219 239.1094 66.5781 239.1094 69.2383C239.1094 71.8984 241.2617 74.0508 243.9219 74.0508C246.582 74.0508 248.7344 71.8984 248.7344 69.2383Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(.55 0 0 .55 157.5055 21.46347)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M268.578 69.2383C268.578 66.5781 266.422 64.4219 263.766 64.4219C261.105 64.4219 258.949 66.5781 258.949 69.2383C258.949 71.8984 261.105 74.0508 263.766 74.0508C266.422 74.0508 268.578 71.8984 268.578 69.2383Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M268.578 69.2383C268.578 66.5781 266.422 64.4219 263.766 64.4219C261.105 64.4219 258.949 66.5781 258.949 69.2383C258.949 71.8984 261.105 74.0508 263.766 74.0508C266.422 74.0508 268.578 71.8984 268.578 69.2383Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(.55 0 0 .55 177.3485 21.46347)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;6&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M288.422 69.2383C288.422 66.5781 286.266 64.4219 283.609 64.4219C280.949 64.4219 278.793 66.5781 278.793 69.2383C278.793 71.8984 280.949 74.0508 283.609 74.0508C286.266 74.0508 288.422 71.8984 288.422 69.2383Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M288.422 69.2383C288.422 66.5781 286.266 64.4219 283.609 64.4219C280.949 64.4219 278.793 66.5781 278.793 69.2383C278.793 71.8984 280.949 74.0508 283.609 74.0508C286.266 74.0508 288.422 71.8984 288.422 69.2383Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(.55 0 0 .55 197.1915 21.46347)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;7&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M308.266 69.2383C308.266 66.5781 306.109 64.4219 303.449 64.4219C300.793 64.4219 298.637 66.5781 298.637 69.2383C298.637 71.8984 300.793 74.0508 303.449 74.0508C306.109 74.0508 308.266 71.8984 308.266 69.2383Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M308.266 69.2383C308.266 66.5781 306.109 64.4219 303.449 64.4219C300.793 64.4219 298.637 66.5781 298.637 69.2383C298.637 71.8984 300.793 74.0508 303.449 74.0508C306.109 74.0508 308.266 71.8984 308.266 69.2383Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;90.072582&#x27; transform=&#x27;matrix(.55 0 0 .55 217.0335 21.46347)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;svg&gt;

	
		&lt;figcaption  style=&quot;font-style: italic;&quot;&gt;Partial Segment Tree&lt;&#x2F;figcaption&gt;
	

&lt;&#x2F;figure&gt;
&lt;p&gt;We can continue and create a &lt;em&gt;binary tree&lt;&#x2F;em&gt;, where each node has two children.&lt;&#x2F;p&gt;
&lt;p&gt;The nice thing about setting up a tree where nodes have a constant number of children (two) is that we can index children of node $i$ as $2 * i$ and $2*i + 1$. Conversely, the parent of $i$ would be $i&#x2F;2$.&lt;&#x2F;p&gt;
&lt;p&gt;(Take a moment to convice yourself this works - this exploits the division implementation common in most languages - we always truncate the result, so &lt;code&gt;(2*i)&#x2F;2&lt;&#x2F;code&gt; and &lt;code&gt;(2*i + 1)&#x2F;2&lt;&#x2F;code&gt; are both equal to &lt;code&gt;i&lt;&#x2F;code&gt;)&lt;&#x2F;p&gt;


&lt;figure class=&quot;center size-smallish&quot;&gt;&lt;!--Add proper accessibility to svgs: https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;4756461&#x2F;10147642 - if you&#x27;re reading this in DevTools, and have an idea of how to, feel free to write to me!--&gt;
	
	&lt;?xml version=&#x27;1.0&#x27; encoding=&#x27;UTF-8&#x27;?&gt;
&lt;!-- This file was generated by dvisvgm 3.2.2 --&gt;
&lt;svg version=&#x27;1.1&#x27; xmlns=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;2000&#x2F;svg&#x27; xmlns:xlink=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xlink&#x27;   viewBox=&#x27;154.429651 -.00025 159.140599 134.304966&#x27;&gt;
&lt;style type=&#x27;text&#x2F;css&#x27;&gt;
&lt;![CDATA[@font-face{font-family:cmr10;src:url(data:application&#x2F;x-font-ttf;base64,AAEAAAAKAIAAAwAgT1MvMoVLdCkAAACsAAAAYGNtYXAADACMAAABDAAAADRnbHlm14gP0wAAAUAAAAYUaGVhZCftHkMAAAdUAAAANmhoZWEFEAGSAAAHjAAAACRobXR4BZ0AzQAAB7AAAAAabG9jYQcUCJYAAAfMAAAAGG1heHAADwBAAAAH5AAAACBuYW1lguMqqQAACAQAAAE4cG9zdAADAAEAAAk8AAAAIAADAgsBkAAFAAACmgLN&#x2F;hQAjwKaAs0B7AHsADMBCQAAAAAGAAAAAAAAAAAAAAEAAAAAAAAAAAAAAABkc3ZnAAYAMAA5AwD&#x2F;AAAAAwABAAAAAAEAAAAAAAAAAAAA&#x2F;&#x2F;8AAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAIAAAAAQABAABAAAAOf&#x2F;&#x2F;AAAAMP&#x2F;&#x2F;&#x2F;9EAAQAAAAAAAgAn&#x2F;+cB2AKsABYALgAAARYGBw4BJwYmJy4BNDY3PgEXNhYXHgEDFjY3Ni8BJicuAQcmDwEGBwYfARYXHgEB1wEPGCRjKydfIx8QDxghYi8jZSYaENkkRg4OAwECBxJLHBYmBiYSCgIBAggQRwFIPXU2RzICASw9O4F4djVGNQECLUg5ef57ATlIYXNmNixJMQMEFgMYVlZmbDwwSTQAAAEAWwAAAa0CqwAYAAABEQYWOwEVJyMHNTMyNicRDgEnNRY2NzYWAS0DIEIhUapRIUMfAylMERxsMxEHAo&#x2F;9whwVIAMDIBUcAhITCAEfAhUvAQoAAAEAMwAAAc0CqgArAAA3Mzc2NzY&#x2F;ATMHITc2PwE+ATc0JiciBgc3HgEVDgEnBiYnPgE3HgEXFgcGB4K4NyIJBwYJGh3+hAECCMUsPwFERi1KEw0bHAIlDwUuAwFnWF94AgEzNnVPAQEGDRszshgHB9swdT1CYwI2MgEBIBQfGQECEylHbwMBbVlIPj9mAAAAAAEAK&#x2F;&#x2F;pAdQCqQA3AAABHgEXDgEHLgEnPgEXMhYUBiceAjY3NCYnIwY2FzcWPgInLgEHJgYHNhYXFAYjJic+ATIeAQYBKVFZAQJ5X1Z3AgElExghJxweXEhLAzs+LRoDDSgUMCsKAQI+Ih5RGQ4vAhwYMAQCZJxtAU4BaBFnQVFyAwFZRyIbAR45HgMsIwFFZk1cAQMcAQMBEkhFDEMwAQEbJQIQJRceATU7T019YQAAAgAdAAAB4gK4ABoAHQAAJSE1ATYXMhYHETMVIxUGFjsBFScjBzUzMjYnNxEDAS3+8AE6CQwMBQFmZgIZNxVFjEQVNxkCBvqpIAHgDwMLD&#x2F;4uIFkcFCADAyAUHHkBfv6CAAAAAAEAM&#x2F;&#x2F;pAcwCqgA9AAAlDgEHLgEnPgEXHgEUBgciJx4BFzY3PgEnNicuAScOAQcGIyI3ESYzNhcWNz4BPwEWFRQPAQYHJicVNhceAQHMA4BcV2IBAiQMGhoaGg4DDlA4SCYRCQEDFgYpKD0&#x2F;CAQJEgMCDQIKSj40SA8JCiwQM1c0IzhKVWzOZH4DBHJGIxQBAR4mHgECL0MBA0AhTh1LNhAwAgQ1DwkaAS8ZAQQfAgEVCAMBCg4nDCYEAgzINQEDfwAAAAACACv&#x2F;5gHUAqoAKAA8AAATPgE3HgEXDgEHBicmJyYnNj8BNjceARUOAS4BJz4BFy4BByYHBgcGBxMWNjc+ATQmJy4BBw4BFwYWFx4BhxA8NFd0AgJ5WEM+Dg03AwRNCVBjQEIBIB8dAQIpDRI0FCE0GBcsA3oSOxgNBgYOGTkNRDoBAQYOBDEBUCc8AgJ&#x2F;Y2h9AwM7DhNNtaReDFcBAT8vHRUBGBchDgEaEAEDHxMiP5j+ngIZLBxIS0ocLhQCBHNAEF0nDzsAAAEAOf&#x2F;pAfECtAAhAAABBw4BBwYdARYGBy4BNyY2PwIFBgcGDwEjNzMGFjsBBwYB54ohHAIMAQ4iIQ8BATtESCv++CcJCwYJGiIaASpa+QECAnDDMmkUU1U0CiwDAywKUMdqZT0BAQUMITDTDhMVBgADACv&#x2F;6QHVAqoACwApADUAABMXPgE3LgEiBgcGFh8BFhceAQcOAQcuASc+ATcnJicuATc+ATceARcOAQcOARceATI2Ny4BJ6d&#x2F;LzUBAlFxUQIBErdEFA4cFwECellUfQMEXzArFgkfDwECaE9JbAMBQp9AOQECXIZdAgIzGAHUUhtILDlFOS8NLnksDw4hQRxUbAMBX1JLXBUeDwolPg5JYAIBUEgzT0clWy1CUkc5LjQPAAACACv&#x2F;6QHUAq0AKQA+AAABDgEHLgEnNDY3Nhc2FxYXFhcOAQciJic+ARcyFhcWBgceATcWNzY3NjcHPgEnNCYnLgEnJgYHDgEXBhYXHgEBeBI&#x2F;L1hzAiIgQlRAPA8ONQMEl2ZCSwEBIA4RHQEBFiAWPw8qMQ4OLAN&#x2F;QjwBBwoNMSQcNRUQBwEBBg4ZOQFGLTkBAoBjOEwhQwIDNxAVTbOnvgM7NB4UARcYDiABGgwBAykOFT2ZLgNyQyVSGSMtAQEbJh1GKiZJHS4UAAABAAAAAQAAcpK4s18PPPUAAwQAAAAAAOMq7VQAAAAA4yrtVAAA&#x2F;+YCgAK4AAAACAACAAAAAAAAAAEAAAMA&#x2F;wAAAAKAAB0ADwHxAAEAAAAAAAAAAAAAAAAAAAACAoAAAAIAACcAWwAzACsAHQAzACsAOQArACsAAAAAAAAAUAB6AMIBGgFMAa4CEgJKAqQDCgABAAAACwA&#x2F;AAMAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgB+AAEAAAAAAAEADwAAAAEAAAAAAAQABQAPAAEAAAAAAAUACwAUAAEAAAAAAAYABQAfAAEAAAAAAAoAGgAkAAMAAQQJAAEAHgA+AAMAAQQJAAQACgBcAAMAAQQJAAUAFgBmAAMAAQQJAAYACgB8AAMAAQQJAAoANACGQ29tcHV0ZXIgTW9kZXJuY21yMTBWZXJzaW9uIDEuMGNtcjEwR2VuZXJhdGVkIGJ5IGR2aXN2Z20gMy4yLjIAQwBvAG0AcAB1AHQAZQByACAATQBvAGQAZQByAG4AYwBtAHIAMQAwAFYAZQByAHMAaQBvAG4AIAAxAC4AMABjAG0AcgAxADAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABkAHYAaQBzAHYAZwBtACAAMwAuADIALgAyAAMAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=) format(&#x27;truetype&#x27;);}
text.f0 {font-family:cmr10;font-size:9.96264px}
]]&gt;
&lt;&#x2F;style&gt;
&lt;g id=&#x27;page1&#x27;&gt;
&lt;path d=&#x27;M154.628901 134.105466H313.371M154.628901 114.2695H313.371M154.628901 134.105466V114.2617M174.4727 134.105466V114.2617M194.3164 134.105466V114.2617M214.1562 134.105466V114.2617M234 134.105466V114.2617M253.8437 134.105466V114.2617M273.687 134.105466V114.2617M293.527 134.105466V114.2617M313.363 134.105466V114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 7.431 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 27.273 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 47.116 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 66.959 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 86.801 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 106.644 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 126.487 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 146.329 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M183.2266 84.5C183.2266 79.6641 179.3086 75.7461 174.4727 75.7461C169.6367 75.7461 165.7187 79.6641 165.7187 84.5C165.7187 89.332 169.6367 93.2539 174.4727 93.2539C179.3086 93.2539 183.2266 89.332 183.2266 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 17.352 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M171.6406 92.9922L164.55078 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M177.3047 92.9922L184.3945 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 84.5C222.9102 79.6641 218.9922 75.7461 214.1562 75.7461C209.3242 75.7461 205.4062 79.6641 205.4062 84.5C205.4062 89.332 209.3242 93.2539 214.1562 93.2539C218.9922 93.2539 222.9102 89.332 222.9102 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 57.037 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M211.3281 92.9922L204.2383 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M216.9883 92.9922L224.0781 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.598 84.5C262.598 79.6641 258.676 75.7461 253.8437 75.7461C249.0078 75.7461 245.0898 79.6641 245.0898 84.5C245.0898 89.332 249.0078 93.2539 253.8437 93.2539C258.676 93.2539 262.598 89.332 262.598 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 96.723 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M251.0156 92.9922L243.9219 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M256.676 92.9922L263.766 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M302.281 84.5C302.281 79.6641 298.363 75.7461 293.527 75.7461C288.695 75.7461 284.777 79.6641 284.777 84.5C284.777 89.332 288.695 93.2539 293.527 93.2539C298.363 93.2539 302.281 89.332 302.281 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 136.408 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M290.699 92.9922L283.609 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M296.363 92.9922L303.449 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M168.4883 113.2695C168.4883 111.0977 166.7266 109.332 164.55078 109.332C162.375 109.332 160.61328 111.0977 160.61328 113.2695C160.61328 115.4453 162.375 117.2109 164.55078 117.2109C166.7266 117.2109 168.4883 115.4453 168.4883 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M168.4883 113.2695C168.4883 111.0977 166.7266 109.332 164.55078 109.332C162.375 109.332 160.61328 111.0977 160.61328 113.2695C160.61328 115.4453 162.375 117.2109 164.55078 117.2109C166.7266 117.2109 168.4883 115.4453 168.4883 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 93.8475 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.332 113.2695C188.332 111.0977 186.5703 109.332 184.3945 109.332S180.457 111.0977 180.457 113.2695C180.457 115.4453 182.2187 117.2109 184.3945 117.2109S188.332 115.4453 188.332 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M188.332 113.2695C188.332 111.0977 186.5703 109.332 184.3945 109.332S180.457 111.0977 180.457 113.2695C180.457 115.4453 182.2187 117.2109 184.3945 117.2109S188.332 115.4453 188.332 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 113.6895 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M208.9961 113.2695C208.9961 110.6445 206.8633 108.5117 204.2383 108.5117C201.6094 108.5117 199.4805 110.6445 199.4805 113.2695C199.4805 115.8984 201.6094 118.0273 204.2383 118.0273C206.8633 118.0273 208.9961 115.8984 208.9961 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M208.9961 113.2695C208.9961 110.6445 206.8633 108.5117 204.2383 108.5117C201.6094 108.5117 199.4805 110.6445 199.4805 113.2695C199.4805 115.8984 201.6094 118.0273 204.2383 118.0273C206.8633 118.0273 208.9961 115.8984 208.9961 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 132.4115 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;10&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M228.8359 113.2695C228.8359 110.6445 226.707 108.5117 224.0781 108.5117C221.4531 108.5117 219.3203 110.6445 219.3203 113.2695C219.3203 115.8984 221.4531 118.0273 224.0781 118.0273C226.707 118.0273 228.8359 115.8984 228.8359 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M228.8359 113.2695C228.8359 110.6445 226.707 108.5117 224.0781 108.5117C221.4531 108.5117 219.3203 110.6445 219.3203 113.2695C219.3203 115.8984 221.4531 118.0273 224.0781 118.0273C226.707 118.0273 228.8359 115.8984 228.8359 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 152.2545 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;11&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M248.6797 113.2695C248.6797 110.6445 246.5508 108.5117 243.9219 108.5117S239.1641 110.6445 239.1641 113.2695C239.1641 115.8984 241.293 118.0273 243.9219 118.0273S248.6797 115.8984 248.6797 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M248.6797 113.2695C248.6797 110.6445 246.5508 108.5117 243.9219 108.5117S239.1641 110.6445 239.1641 113.2695C239.1641 115.8984 241.293 118.0273 243.9219 118.0273S248.6797 115.8984 248.6797 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 172.0965 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;12&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M268.523 113.2695C268.523 110.6445 266.395 108.5117 263.766 108.5117S259.008 110.6445 259.008 113.2695C259.008 115.8984 261.137 118.0273 263.766 118.0273S268.523 115.8984 268.523 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M268.523 113.2695C268.523 110.6445 266.395 108.5117 263.766 108.5117S259.008 110.6445 259.008 113.2695C259.008 115.8984 261.137 118.0273 263.766 118.0273S268.523 115.8984 268.523 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 191.9395 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;13&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M288.367 113.2695C288.367 110.6445 286.234 108.5117 283.609 108.5117C280.98 108.5117 278.848 110.6445 278.848 113.2695C278.848 115.8984 280.98 118.0273 283.609 118.0273C286.234 118.0273 288.367 115.8984 288.367 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M288.367 113.2695C288.367 110.6445 286.234 108.5117 283.609 108.5117C280.98 108.5117 278.848 110.6445 278.848 113.2695C278.848 115.8984 280.98 118.0273 283.609 118.0273C286.234 118.0273 288.367 115.8984 288.367 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 211.7825 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;14&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M308.207 113.2695C308.207 110.6445 306.078 108.5117 303.449 108.5117C300.824 108.5117 298.691 110.6445 298.691 113.2695C298.691 115.8984 300.824 118.0273 303.449 118.0273C306.078 118.0273 308.207 115.8984 308.207 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M308.207 113.2695C308.207 110.6445 306.078 108.5117 303.449 108.5117C300.824 108.5117 298.691 110.6445 298.691 113.2695C298.691 115.8984 300.824 118.0273 303.449 118.0273C306.078 118.0273 308.207 115.8984 308.207 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 231.6245 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;15&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M204.8203 54.7344C204.8203 48.9336 200.1172 44.2305 194.3164 44.2305S183.8125 48.9336 183.8125 54.7344S188.5156 65.2383 194.3164 65.2383S204.8203 60.5352 204.8203 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 5.771 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.3555 63.6719L179.4375 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M200.2773 63.6719L209.1953 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M284.191 54.7344C284.191 48.9336 279.488 44.2305 273.687 44.2305C267.887 44.2305 263.184 48.9336 263.184 54.7344S267.887 65.2383 273.687 65.2383C279.488 65.2383 284.191 60.5352 284.191 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 85.141 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M267.73 63.6719L258.812 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M279.648 63.6719L288.566 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M178.4102 75.5703C178.4102 73.3945 176.6484 71.6328 174.4727 71.6328C172.2969 71.6328 170.5352 73.3945 170.5352 75.5703S172.2969 79.5078 174.4727 79.5078C176.6484 79.5078 178.4102 77.7461 178.4102 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M178.4102 75.5703C178.4102 73.3945 176.6484 71.6328 174.4727 71.6328C172.2969 71.6328 170.5352 73.3945 170.5352 75.5703S172.2969 79.5078 174.4727 79.5078C176.6484 79.5078 178.4102 77.7461 178.4102 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 103.7685 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M218.0977 75.5703C218.0977 73.3945 216.332 71.6328 214.1562 71.6328C211.9844 71.6328 210.2187 73.3945 210.2187 75.5703S211.9844 79.5078 214.1562 79.5078C216.332 79.5078 218.0977 77.7461 218.0977 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M218.0977 75.5703C218.0977 73.3945 216.332 71.6328 214.1562 71.6328C211.9844 71.6328 210.2187 73.3945 210.2187 75.5703S211.9844 79.5078 214.1562 79.5078C216.332 79.5078 218.0977 77.7461 218.0977 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 143.4535 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M257.781 75.5703C257.781 73.3945 256.02 71.6328 253.8437 71.6328C251.668 71.6328 249.9062 73.3945 249.9062 75.5703S251.668 79.5078 253.8437 79.5078C256.02 79.5078 257.781 77.7461 257.781 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M257.781 75.5703C257.781 73.3945 256.02 71.6328 253.8437 71.6328C251.668 71.6328 249.9062 73.3945 249.9062 75.5703S251.668 79.5078 253.8437 79.5078C256.02 79.5078 257.781 77.7461 257.781 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 183.1395 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;6&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M297.469 75.5703C297.469 73.3945 295.703 71.6328 293.527 71.6328C291.352 71.6328 289.59 73.3945 289.59 75.5703S291.352 79.5078 293.527 79.5078C295.703 79.5078 297.469 77.7461 297.469 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M297.469 75.5703C297.469 73.3945 295.703 71.6328 293.527 71.6328C291.352 71.6328 289.59 73.3945 289.59 75.5703S291.352 79.5078 293.527 79.5078C295.703 79.5078 297.469 77.7461 297.469 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 222.8245 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;7&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M244.9414 15.051C244.9414 9.008 240.043 4.109 234 4.109S223.0586 9.008 223.0586 15.051S227.957 25.992 234 25.992S244.9414 21.094 244.9414 15.051Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.25 0 0 1.25 37.5995 -148.5698)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M226.0898 22.961L201.9141 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M241.9141 22.961L266.094 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M198.2539 43.8203C198.2539 41.6445 196.4922 39.8828 194.3164 39.8828S190.375 41.6445 190.375 43.8203S192.1406 47.7617 194.3164 47.7617S198.2539 45.9961 198.2539 43.8203Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M198.2539 43.8203C198.2539 41.6445 196.4922 39.8828 194.3164 39.8828S190.375 41.6445 190.375 43.8203S192.1406 47.7617 194.3164 47.7617S198.2539 45.9961 198.2539 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 123.6115 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M277.625 43.8203C277.625 41.6445 275.863 39.8828 273.687 39.8828C271.512 39.8828 269.746 41.6445 269.746 43.8203S271.512 47.7617 273.687 47.7617C275.863 47.7617 277.625 45.9961 277.625 43.8203Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M277.625 43.8203C277.625 41.6445 275.863 39.8828 273.687 39.8828C271.512 39.8828 269.746 41.6445 269.746 43.8203S271.512 47.7617 273.687 47.7617C275.863 47.7617 277.625 45.9961 277.625 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 202.9815 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M237.9414 4.137C237.9414 1.961 236.1758 .199 234 .199S230.0625 1.961 230.0625 4.137C230.0625 6.312 231.8242 8.074 234 8.074S237.9414 6.312 237.9414 4.137Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M237.9414 4.137C237.9414 1.961 236.1758 .199 234 .199S230.0625 1.961 230.0625 4.137C230.0625 6.312 231.8242 8.074 234 8.074S237.9414 6.312 237.9414 4.137Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 163.2965 -54.76671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;svg&gt;

	
		&lt;figcaption  style=&quot;font-style: italic;&quot;&gt;Segment Tree with indices&lt;&#x2F;figcaption&gt;
	

&lt;&#x2F;figure&gt;
&lt;p&gt;The key benefit to cutting ranges into smaller ranges this way is that we only need to edit one half of the range in case of an update: for example, to change the value of index $3$ to 9, &lt;strong&gt;we only need to modify $[3]$ and its &lt;em&gt;ancestors&lt;&#x2F;em&gt; &lt;nobr&gt;($[3, 4], [1, 4], [1, 8]$)&lt;&#x2F;nobr&gt; and not bother with the other nodes&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;em&gt;This is the observation that leads to our $O(\log N)$ query and update time.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;!-- &lt;nobr&gt; ref: https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;30308032&#x2F;markdown-no-break-nobr --&gt;


&lt;figure class=&quot;center size-medium&quot;&gt;&lt;!--Add proper accessibility to svgs: https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;4756461&#x2F;10147642 - if you&#x27;re reading this in DevTools, and have an idea of how to, feel free to write to me!--&gt;
	
	&lt;?xml version=&#x27;1.0&#x27; encoding=&#x27;UTF-8&#x27;?&gt;
&lt;!-- This file was generated by dvisvgm 3.2.2 --&gt;
&lt;svg version=&#x27;1.1&#x27; xmlns=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;2000&#x2F;svg&#x27; xmlns:xlink=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xlink&#x27;   viewBox=&#x27;154.429651 -.00025 159.140599 134.304966&#x27;&gt;
&lt;style type=&#x27;text&#x2F;css&#x27;&gt;
&lt;![CDATA[@font-face{font-family:cmr10;src:url(data:application&#x2F;x-font-ttf;base64,AAEAAAAKAIAAAwAgT1MvMoVLdCkAAACsAAAAYGNtYXAADACMAAABDAAAADRnbHlm14gP0wAAAUAAAAYUaGVhZCftHkUAAAdUAAAANmhoZWEFEAGSAAAHjAAAACRobXR4BZ0AzQAAB7AAAAAabG9jYQcUCJYAAAfMAAAAGG1heHAADwBAAAAH5AAAACBuYW1lguMqqQAACAQAAAE4cG9zdAADAAEAAAk8AAAAIAADAgsBkAAFAAACmgLN&#x2F;hQAjwKaAs0B7AHsADMBCQAAAAAGAAAAAAAAAAAAAAEAAAAAAAAAAAAAAABkc3ZnAAYAMAA5AwD&#x2F;AAAAAwABAAAAAAEAAAAAAAAAAAAA&#x2F;&#x2F;8AAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAIAAAAAQABAABAAAAOf&#x2F;&#x2F;AAAAMP&#x2F;&#x2F;&#x2F;9EAAQAAAAAAAgAn&#x2F;+cB2AKsABYALgAAARYGBw4BJwYmJy4BNDY3PgEXNhYXHgEDFjY3Ni8BJicuAQcmDwEGBwYfARYXHgEB1wEPGCRjKydfIx8QDxghYi8jZSYaENkkRg4OAwECBxJLHBYmBiYSCgIBAggQRwFIPXU2RzICASw9O4F4djVGNQECLUg5ef57ATlIYXNmNixJMQMEFgMYVlZmbDwwSTQAAAEAWwAAAa0CqwAYAAABEQYWOwEVJyMHNTMyNicRDgEnNRY2NzYWAS0DIEIhUapRIUMfAylMERxsMxEHAo&#x2F;9whwVIAMDIBUcAhITCAEfAhUvAQoAAAEAMwAAAc0CqgArAAA3Mzc2NzY&#x2F;ATMHITc2PwE+ATc0JiciBgc3HgEVDgEnBiYnPgE3HgEXFgcGB4K4NyIJBwYJGh3+hAECCMUsPwFERi1KEw0bHAIlDwUuAwFnWF94AgEzNnVPAQEGDRszshgHB9swdT1CYwI2MgEBIBQfGQECEylHbwMBbVlIPj9mAAAAAAEAK&#x2F;&#x2F;pAdQCqQA3AAABHgEXDgEHLgEnPgEXMhYUBiceAjY3NCYnIwY2FzcWPgInLgEHJgYHNhYXFAYjJic+ATIeAQYBKVFZAQJ5X1Z3AgElExghJxweXEhLAzs+LRoDDSgUMCsKAQI+Ih5RGQ4vAhwYMAQCZJxtAU4BaBFnQVFyAwFZRyIbAR45HgMsIwFFZk1cAQMcAQMBEkhFDEMwAQEbJQIQJRceATU7T019YQAAAgAdAAAB4gK4ABoAHQAAJSE1ATYXMhYHETMVIxUGFjsBFScjBzUzMjYnNxEDAS3+8AE6CQwMBQFmZgIZNxVFjEQVNxkCBvqpIAHgDwMLD&#x2F;4uIFkcFCADAyAUHHkBfv6CAAAAAAEAM&#x2F;&#x2F;pAcwCqgA9AAAlDgEHLgEnPgEXHgEUBgciJx4BFzY3PgEnNicuAScOAQcGIyI3ESYzNhcWNz4BPwEWFRQPAQYHJicVNhceAQHMA4BcV2IBAiQMGhoaGg4DDlA4SCYRCQEDFgYpKD0&#x2F;CAQJEgMCDQIKSj40SA8JCiwQM1c0IzhKVWzOZH4DBHJGIxQBAR4mHgECL0MBA0AhTh1LNhAwAgQ1DwkaAS8ZAQQfAgEVCAMBCg4nDCYEAgzINQEDfwAAAAACACv&#x2F;5gHUAqoAKAA8AAATPgE3HgEXDgEHBicmJyYnNj8BNjceARUOAS4BJz4BFy4BByYHBgcGBxMWNjc+ATQmJy4BBw4BFwYWFx4BhxA8NFd0AgJ5WEM+Dg03AwRNCVBjQEIBIB8dAQIpDRI0FCE0GBcsA3oSOxgNBgYOGTkNRDoBAQYOBDEBUCc8AgJ&#x2F;Y2h9AwM7DhNNtaReDFcBAT8vHRUBGBchDgEaEAEDHxMiP5j+ngIZLBxIS0ocLhQCBHNAEF0nDzsAAAEAOf&#x2F;pAfECtAAhAAABBw4BBwYdARYGBy4BNyY2PwIFBgcGDwEjNzMGFjsBBwYB54ohHAIMAQ4iIQ8BATtESCv++CcJCwYJGiIaASpa+QECAnDDMmkUU1U0CiwDAywKUMdqZT0BAQUMITDTDhMVBgADACv&#x2F;6QHVAqoACwApADUAABMXPgE3LgEiBgcGFh8BFhceAQcOAQcuASc+ATcnJicuATc+ATceARcOAQcOARceATI2Ny4BJ6d&#x2F;LzUBAlFxUQIBErdEFA4cFwECellUfQMEXzArFgkfDwECaE9JbAMBQp9AOQECXIZdAgIzGAHUUhtILDlFOS8NLnksDw4hQRxUbAMBX1JLXBUeDwolPg5JYAIBUEgzT0clWy1CUkc5LjQPAAACACv&#x2F;6QHUAq0AKQA+AAABDgEHLgEnNDY3Nhc2FxYXFhcOAQciJic+ARcyFhcWBgceATcWNzY3NjcHPgEnNCYnLgEnJgYHDgEXBhYXHgEBeBI&#x2F;L1hzAiIgQlRAPA8ONQMEl2ZCSwEBIA4RHQEBFiAWPw8qMQ4OLAN&#x2F;QjwBBwoNMSQcNRUQBwEBBg4ZOQFGLTkBAoBjOEwhQwIDNxAVTbOnvgM7NB4UARcYDiABGgwBAykOFT2ZLgNyQyVSGSMtAQEbJh1GKiZJHS4UAAABAAAAAQAAcpK4r18PPPUAAwQAAAAAAOMq7VUAAAAA4yrtVQAA&#x2F;+YCgAK4AAAACAACAAAAAAAAAAEAAAMA&#x2F;wAAAAKAAB0ADwHxAAEAAAAAAAAAAAAAAAAAAAACAoAAAAIAACcAWwAzACsAHQAzACsAOQArACsAAAAAAAAAUAB6AMIBGgFMAa4CEgJKAqQDCgABAAAACwA&#x2F;AAMAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgB+AAEAAAAAAAEADwAAAAEAAAAAAAQABQAPAAEAAAAAAAUACwAUAAEAAAAAAAYABQAfAAEAAAAAAAoAGgAkAAMAAQQJAAEAHgA+AAMAAQQJAAQACgBcAAMAAQQJAAUAFgBmAAMAAQQJAAYACgB8AAMAAQQJAAoANACGQ29tcHV0ZXIgTW9kZXJuY21yMTBWZXJzaW9uIDEuMGNtcjEwR2VuZXJhdGVkIGJ5IGR2aXN2Z20gMy4yLjIAQwBvAG0AcAB1AHQAZQByACAATQBvAGQAZQByAG4AYwBtAHIAMQAwAFYAZQByAHMAaQBvAG4AIAAxAC4AMABjAG0AcgAxADAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABkAHYAaQBzAHYAZwBtACAAMwAuADIALgAyAAMAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=) format(&#x27;truetype&#x27;);}
text.f0 {font-family:cmr10;font-size:9.96264px}
]]&gt;
&lt;&#x2F;style&gt;
&lt;g id=&#x27;page1&#x27;&gt;
&lt;path d=&#x27;M194.3164 134.105466V114.2617H214.1562V134.105466Z&#x27; fill=&#x27;var(--diagram-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M154.628901 134.105466H313.371M154.628901 114.2695H313.371M154.628901 134.105466V114.2617M174.4727 134.105466V114.2617M194.3164 134.105466V114.2617M214.1562 134.105466V114.2617M234 134.105466V114.2617M253.8437 134.105466V114.2617M273.687 134.105466V114.2617M293.527 134.105466V114.2617M313.363 134.105466V114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 7.431 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 27.273 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 47.116 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 66.959 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 86.801 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 106.644 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 126.487 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 146.329 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M183.2266 84.5C183.2266 79.6641 179.3086 75.7461 174.4727 75.7461C169.6367 75.7461 165.7187 79.6641 165.7187 84.5C165.7187 89.332 169.6367 93.2539 174.4727 93.2539C179.3086 93.2539 183.2266 89.332 183.2266 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 17.352 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M171.6406 92.9922L164.55078 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M177.3047 92.9922L184.3945 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 84.5C222.9102 79.6641 218.9922 75.7461 214.1562 75.7461C209.3242 75.7461 205.4062 79.6641 205.4062 84.5C205.4062 89.332 209.3242 93.2539 214.1562 93.2539C218.9922 93.2539 222.9102 89.332 222.9102 84.5Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 84.5C222.9102 79.6641 218.9922 75.7461 214.1562 75.7461C209.3242 75.7461 205.4062 79.6641 205.4062 84.5C205.4062 89.332 209.3242 93.2539 214.1562 93.2539C218.9922 93.2539 222.9102 89.332 222.9102 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 57.037 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M211.3281 92.9922L204.2383 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M216.9883 92.9922L224.0781 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.598 84.5C262.598 79.6641 258.676 75.7461 253.8437 75.7461C249.0078 75.7461 245.0898 79.6641 245.0898 84.5C245.0898 89.332 249.0078 93.2539 253.8437 93.2539C258.676 93.2539 262.598 89.332 262.598 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 96.723 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M251.0156 92.9922L243.9219 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M256.676 92.9922L263.766 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M302.281 84.5C302.281 79.6641 298.363 75.7461 293.527 75.7461C288.695 75.7461 284.777 79.6641 284.777 84.5C284.777 89.332 288.695 93.2539 293.527 93.2539C298.363 93.2539 302.281 89.332 302.281 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 136.408 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M290.699 92.9922L283.609 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M296.363 92.9922L303.449 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M168.4883 113.2695C168.4883 111.0977 166.7266 109.332 164.55078 109.332C162.375 109.332 160.61328 111.0977 160.61328 113.2695C160.61328 115.4453 162.375 117.2109 164.55078 117.2109C166.7266 117.2109 168.4883 115.4453 168.4883 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M168.4883 113.2695C168.4883 111.0977 166.7266 109.332 164.55078 109.332C162.375 109.332 160.61328 111.0977 160.61328 113.2695C160.61328 115.4453 162.375 117.2109 164.55078 117.2109C166.7266 117.2109 168.4883 115.4453 168.4883 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 93.8475 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.332 113.2695C188.332 111.0977 186.5703 109.332 184.3945 109.332S180.457 111.0977 180.457 113.2695C180.457 115.4453 182.2187 117.2109 184.3945 117.2109S188.332 115.4453 188.332 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M188.332 113.2695C188.332 111.0977 186.5703 109.332 184.3945 109.332S180.457 111.0977 180.457 113.2695C180.457 115.4453 182.2187 117.2109 184.3945 117.2109S188.332 115.4453 188.332 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 113.6895 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M208.9961 113.2695C208.9961 110.6445 206.8633 108.5117 204.2383 108.5117C201.6094 108.5117 199.4805 110.6445 199.4805 113.2695C199.4805 115.8984 201.6094 118.0273 204.2383 118.0273C206.8633 118.0273 208.9961 115.8984 208.9961 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M208.9961 113.2695C208.9961 110.6445 206.8633 108.5117 204.2383 108.5117C201.6094 108.5117 199.4805 110.6445 199.4805 113.2695C199.4805 115.8984 201.6094 118.0273 204.2383 118.0273C206.8633 118.0273 208.9961 115.8984 208.9961 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 132.4115 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;10&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M228.8359 113.2695C228.8359 110.6445 226.707 108.5117 224.0781 108.5117C221.4531 108.5117 219.3203 110.6445 219.3203 113.2695C219.3203 115.8984 221.4531 118.0273 224.0781 118.0273C226.707 118.0273 228.8359 115.8984 228.8359 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M228.8359 113.2695C228.8359 110.6445 226.707 108.5117 224.0781 108.5117C221.4531 108.5117 219.3203 110.6445 219.3203 113.2695C219.3203 115.8984 221.4531 118.0273 224.0781 118.0273C226.707 118.0273 228.8359 115.8984 228.8359 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 152.2545 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;11&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M248.6797 113.2695C248.6797 110.6445 246.5508 108.5117 243.9219 108.5117S239.1641 110.6445 239.1641 113.2695C239.1641 115.8984 241.293 118.0273 243.9219 118.0273S248.6797 115.8984 248.6797 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M248.6797 113.2695C248.6797 110.6445 246.5508 108.5117 243.9219 108.5117S239.1641 110.6445 239.1641 113.2695C239.1641 115.8984 241.293 118.0273 243.9219 118.0273S248.6797 115.8984 248.6797 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 172.0965 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;12&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M268.523 113.2695C268.523 110.6445 266.395 108.5117 263.766 108.5117S259.008 110.6445 259.008 113.2695C259.008 115.8984 261.137 118.0273 263.766 118.0273S268.523 115.8984 268.523 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M268.523 113.2695C268.523 110.6445 266.395 108.5117 263.766 108.5117S259.008 110.6445 259.008 113.2695C259.008 115.8984 261.137 118.0273 263.766 118.0273S268.523 115.8984 268.523 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 191.9395 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;13&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M288.367 113.2695C288.367 110.6445 286.234 108.5117 283.609 108.5117C280.98 108.5117 278.848 110.6445 278.848 113.2695C278.848 115.8984 280.98 118.0273 283.609 118.0273C286.234 118.0273 288.367 115.8984 288.367 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M288.367 113.2695C288.367 110.6445 286.234 108.5117 283.609 108.5117C280.98 108.5117 278.848 110.6445 278.848 113.2695C278.848 115.8984 280.98 118.0273 283.609 118.0273C286.234 118.0273 288.367 115.8984 288.367 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 211.7825 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;14&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M308.207 113.2695C308.207 110.6445 306.078 108.5117 303.449 108.5117C300.824 108.5117 298.691 110.6445 298.691 113.2695C298.691 115.8984 300.824 118.0273 303.449 118.0273C306.078 118.0273 308.207 115.8984 308.207 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M308.207 113.2695C308.207 110.6445 306.078 108.5117 303.449 108.5117C300.824 108.5117 298.691 110.6445 298.691 113.2695C298.691 115.8984 300.824 118.0273 303.449 118.0273C306.078 118.0273 308.207 115.8984 308.207 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 231.6245 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;15&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M204.8203 54.7344C204.8203 48.9336 200.1172 44.2305 194.3164 44.2305S183.8125 48.9336 183.8125 54.7344S188.5156 65.2383 194.3164 65.2383S204.8203 60.5352 204.8203 54.7344Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M204.8203 54.7344C204.8203 48.9336 200.1172 44.2305 194.3164 44.2305S183.8125 48.9336 183.8125 54.7344S188.5156 65.2383 194.3164 65.2383S204.8203 60.5352 204.8203 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 5.771 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.3555 63.6719L179.4375 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M200.2773 63.6719L209.1953 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M284.191 54.7344C284.191 48.9336 279.488 44.2305 273.687 44.2305C267.887 44.2305 263.184 48.9336 263.184 54.7344S267.887 65.2383 273.687 65.2383C279.488 65.2383 284.191 60.5352 284.191 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 85.141 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M267.73 63.6719L258.812 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M279.648 63.6719L288.566 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M178.4102 75.5703C178.4102 73.3945 176.6484 71.6328 174.4727 71.6328C172.2969 71.6328 170.5352 73.3945 170.5352 75.5703S172.2969 79.5078 174.4727 79.5078C176.6484 79.5078 178.4102 77.7461 178.4102 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M178.4102 75.5703C178.4102 73.3945 176.6484 71.6328 174.4727 71.6328C172.2969 71.6328 170.5352 73.3945 170.5352 75.5703S172.2969 79.5078 174.4727 79.5078C176.6484 79.5078 178.4102 77.7461 178.4102 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 103.7685 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M218.0977 75.5703C218.0977 73.3945 216.332 71.6328 214.1562 71.6328C211.9844 71.6328 210.2187 73.3945 210.2187 75.5703S211.9844 79.5078 214.1562 79.5078C216.332 79.5078 218.0977 77.7461 218.0977 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M218.0977 75.5703C218.0977 73.3945 216.332 71.6328 214.1562 71.6328C211.9844 71.6328 210.2187 73.3945 210.2187 75.5703S211.9844 79.5078 214.1562 79.5078C216.332 79.5078 218.0977 77.7461 218.0977 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 143.4535 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M257.781 75.5703C257.781 73.3945 256.02 71.6328 253.8437 71.6328C251.668 71.6328 249.9062 73.3945 249.9062 75.5703S251.668 79.5078 253.8437 79.5078C256.02 79.5078 257.781 77.7461 257.781 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M257.781 75.5703C257.781 73.3945 256.02 71.6328 253.8437 71.6328C251.668 71.6328 249.9062 73.3945 249.9062 75.5703S251.668 79.5078 253.8437 79.5078C256.02 79.5078 257.781 77.7461 257.781 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 183.1395 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;6&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M297.469 75.5703C297.469 73.3945 295.703 71.6328 293.527 71.6328C291.352 71.6328 289.59 73.3945 289.59 75.5703S291.352 79.5078 293.527 79.5078C295.703 79.5078 297.469 77.7461 297.469 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M297.469 75.5703C297.469 73.3945 295.703 71.6328 293.527 71.6328C291.352 71.6328 289.59 73.3945 289.59 75.5703S291.352 79.5078 293.527 79.5078C295.703 79.5078 297.469 77.7461 297.469 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 222.8245 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;7&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M244.9414 15.051C244.9414 9.008 240.043 4.109 234 4.109S223.0586 9.008 223.0586 15.051S227.957 25.992 234 25.992S244.9414 21.094 244.9414 15.051Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M244.9414 15.051C244.9414 9.008 240.043 4.109 234 4.109S223.0586 9.008 223.0586 15.051S227.957 25.992 234 25.992S244.9414 21.094 244.9414 15.051Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.25 0 0 1.25 37.5995 -148.5698)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M226.0898 22.961L201.9141 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M241.9141 22.961L266.094 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M198.2539 43.8203C198.2539 41.6445 196.4922 39.8828 194.3164 39.8828S190.375 41.6445 190.375 43.8203S192.1406 47.7617 194.3164 47.7617S198.2539 45.9961 198.2539 43.8203Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M198.2539 43.8203C198.2539 41.6445 196.4922 39.8828 194.3164 39.8828S190.375 41.6445 190.375 43.8203S192.1406 47.7617 194.3164 47.7617S198.2539 45.9961 198.2539 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 123.6115 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M277.625 43.8203C277.625 41.6445 275.863 39.8828 273.687 39.8828C271.512 39.8828 269.746 41.6445 269.746 43.8203S271.512 47.7617 273.687 47.7617C275.863 47.7617 277.625 45.9961 277.625 43.8203Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M277.625 43.8203C277.625 41.6445 275.863 39.8828 273.687 39.8828C271.512 39.8828 269.746 41.6445 269.746 43.8203S271.512 47.7617 273.687 47.7617C275.863 47.7617 277.625 45.9961 277.625 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 202.9815 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M237.9414 4.137C237.9414 1.961 236.1758 .199 234 .199S230.0625 1.961 230.0625 4.137C230.0625 6.312 231.8242 8.074 234 8.074S237.9414 6.312 237.9414 4.137Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M237.9414 4.137C237.9414 1.961 236.1758 .199 234 .199S230.0625 1.961 230.0625 4.137C230.0625 6.312 231.8242 8.074 234 8.074S237.9414 6.312 237.9414 4.137Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 163.2965 -54.76671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;svg&gt;

	
		&lt;figcaption  style=&quot;font-style: italic;&quot;&gt;Segment Tree Change Propagation&lt;&#x2F;figcaption&gt;
	

&lt;&#x2F;figure&gt;
&lt;h4 id=&quot;sidenote-proof-of-memory-complexity&quot;&gt;Sidenote: Proof of Memory Complexity&lt;a class=&quot;zola-anchor&quot; href=&quot;#sidenote-proof-of-memory-complexity&quot; aria-label=&quot;Anchor link for: sidenote-proof-of-memory-complexity&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;Our segment tree consists of levels which are half the size of the previous one (since there is a single parent node for every two child nodes).
Let the number of base nodes be $N = 2^M$.
Therefore, the total number of nodes is:
$$
N + \frac{N}{2} + \frac{N}{4} + ... + 1
$$
or alternatively,
$$
2^{M} + 2^{M - 1} + 2^{M - 2} + ... + 2^{0}
$$&lt;&#x2F;p&gt;
&lt;p&gt;We know,
$$
1 = \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + ... + \frac{1}{\infty}
$$
$$
\implies 2^0 = 2^{-1} + 2^{-2} + 2^{-3} + ... + 2^{-\infty}
$$
$$
\implies 2^{M+1} = 2^{M} + 2^{M-1} + ... + 2^{0} + \underbrace{2^{-1} + 2^{-2} + 2^{-\infty}}_{\text{= 1}}
$$
$$
\implies 2^{M+1} = 2^{M} + 2^{M-1} + ... + 2^{0} + 1
$$
$$
\implies 2^{M+1} &amp;gt; 2^{M} + 2^{M-1} + ... + 2^{0}
$$&lt;&#x2F;p&gt;
&lt;p&gt;Therefore, our Segment Tree will require $2^{M+1} - 1$ memory, or in other words, $2 * N - 1$ memory.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;See &lt;a href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20210812213627&#x2F;https:&#x2F;&#x2F;platonicrealms.com&#x2F;encyclopedia&#x2F;Zenos-Paradox-of-the-Tortoise-and-Achilles&quot;&gt;Zeno&#x27;s Paradox&lt;&#x2F;a&gt; for more detail; specifically that the $1 = \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + ...$ does indeed converge.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h4 id=&quot;sidenote-segment-tree-power&quot;&gt;Sidenote: Segment Tree Power!!!&lt;a class=&quot;zola-anchor&quot; href=&quot;#sidenote-segment-tree-power&quot; aria-label=&quot;Anchor link for: sidenote-segment-tree-power&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h4&gt;
&lt;p&gt;Segment Trees are an extremely flexible data structure - we could also build a segment tree for sum queries. In fact, we can build a segment tree for &lt;em&gt;any&lt;&#x2F;em&gt; operation which is &lt;em&gt;associative&lt;&#x2F;em&gt; (i.e. order of operations doesn&#x27;t matter; $(a \centerdot b) \centerdot c = a \centerdot (b \centerdot c)$).&lt;&#x2F;p&gt;
&lt;p&gt;This property ensures that we can prevaluate range answers and then combine them for the right answer. We can be certain that
$$
\left([1] \centerdot [2]\right) \centerdot \left([3] \centerdot [4]\right) \centerdot [5] = [1] \centerdot [2] \centerdot [3] \centerdot [4] \centerdot [5]
$$&lt;&#x2F;p&gt;
&lt;p&gt;Now that we&#x27;re finished talking about the basic concept of the segment tree, on to implementing it!&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;We define the following functions:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;$\text{build} (\text{arr})$ - actually constructs our segment tree from the array.&lt;&#x2F;li&gt;
&lt;li&gt;$\text{query} (l, r)$ - returns the maximum element in $[l, r]$ range of the array.&lt;&#x2F;li&gt;
&lt;li&gt;$\text{update} (\text{value, index})$ - set element at $\text{index}$ of the array to $\text{value}$. (i.e. set &lt;code&gt;arr[index] = value&lt;&#x2F;code&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Implementation Note:
We&#x27;ll be using the &lt;code&gt;max&lt;&#x2F;code&gt; operation here. The code present below assume &lt;em&gt;commutativity&lt;&#x2F;em&gt;, though supporting non-commutative operations is as simple as ensuring order of operands when modifying the tree. (See my &lt;a href=&quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;competitive-programming&#x2F;dsa-explanations&#x2F;basic-segment-tree&#x2F;code&#x2F;segtree-two-power&#x2F;src&#x2F;generic_segtree.rs&quot;&gt;generic version&lt;&#x2F;a&gt; which does &lt;em&gt;not&lt;&#x2F;em&gt; assume commutativity.)&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;!--Consider using python library manim to animate these operations--&gt;
&lt;h2 id=&quot;building-build&quot;&gt;Building &lt;code&gt;build&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#building-build&quot; aria-label=&quot;Anchor link for: building-build&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;We observe that the indices for the ranges of $[1,1]...[i, i]...[N, N]$ (i.e. the base cases) in the segment tree are $[N, N]...[N + i, N + i]...[2 * N - 1, 2 * N - 1]$, where $N$ is the total number of elements. &lt;small&gt;(Refer to the previous section for an understanding of as to why the total number of nodes in a binary tree are $2*N$)&lt;&#x2F;small&gt;&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;small&gt;In case you&#x27;ve forgotten, the number of elements in a both sides inclusive range $[l, r]$ is $r - l + 1$.&lt;&#x2F;small&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;We fill the second half of the array with our initial elements, then start working our way down. Make sure that you understand why &lt;code&gt;buf[i]&lt;&#x2F;code&gt; is calculated from &lt;code&gt;buf[2*i]&lt;&#x2F;code&gt; and &lt;code&gt;buf[2*i + 1]&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;

	&lt;small&gt;&lt;span class=&quot;codeblock-name&quot;&gt;&lt;a href = &quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;competitive-programming&#x2F;dsa-explanations&#x2F;basic-segment-tree&#x2F;code&#x2F;segtree-two-power&#x2F;src&#x2F;max_segtree.rs&quot;&gt;code&amp;#x2F;segtree-two-power&amp;#x2F;src&amp;#x2F;max_segtree.rs&lt;&#x2F;a&gt;&lt;&#x2F;span&gt;&lt;&#x2F;small&gt;
&lt;pre data-linenos data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-struct z-rust&quot;&gt;struct&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-entity z-name z-struct z-rust&quot;&gt;SegTree&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;const&lt;&#x2F;span&gt; N&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;usize&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;where
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-struct z-rust&quot;&gt;    [u32&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;*&lt;&#x2F;span&gt;N]&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-type z-rust&quot;&gt;Sized&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    buf&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;*&lt;&#x2F;span&gt;N&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-impl z-rust&quot;&gt;impl&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;const&lt;&#x2F;span&gt; N&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;usize&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt; &lt;span class=&quot;z-entity z-name z-impl z-rust&quot;&gt;SegTree&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;N&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-keyword z-other z-rust&quot;&gt;where&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;    [&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;; 2*N]&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; Sized,
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;21&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;new&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;arr&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;[&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;; N]&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;Self&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;22&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;mut&lt;&#x2F;span&gt; buf&lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt;  &lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;default&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;;&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;*&lt;&#x2F;span&gt;N&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;23&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;N&lt;span class=&quot;z-keyword z-operator z-range z-rust&quot;&gt;..&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;*&lt;&#x2F;span&gt;N&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;copy_from_slice&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;arr&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;24&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;for&lt;&#x2F;span&gt; i &lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;in&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-range z-rust&quot;&gt;..&lt;&#x2F;span&gt;N&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-rust&quot;&gt;rev&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;25&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;i&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;max&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;*&lt;&#x2F;span&gt;i&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;*&lt;&#x2F;span&gt;i &lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;+&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;26&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;27&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;28&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        SegTree &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;buf&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;29&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;30&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-impl z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;querying-query&quot;&gt;Querying &lt;code&gt;query&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#querying-query&quot; aria-label=&quot;Anchor link for: querying-query&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;For querying, we start with $[l, l]$ and $[r, r]$ at the lowest level, then move up the tree, ensuring at all times that both of the ranges are subsets of the original query range, $[l, r]$.&lt;&#x2F;p&gt;
&lt;p&gt;We start at $[l, l]$, then merge in rightward ranges moving up to eventually get to $[l, r]$. Similarly, we start at $[r, r]$ and then merge in leftward ranges moving up to eventually get to $[l, r]$.&lt;&#x2F;p&gt;
&lt;p&gt;One observation that we can make is that determining whether a range is a &quot;left child&quot; or a &quot;right child&quot; is that all &quot;left children&quot; have odd indices, while all &quot;right children&quot; have even ones.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;A range, say, $[1, 2]$ will have two children: $[1, 1]$ and $[2, 2]$. Out of these, $[1, 1]$ will be the &quot;left child&quot; and $[2, 2]$ will be the right child. When we&#x27;re at a range, say $[1, 1]$, we can use the index of said range to determine whether merging $[1, 1]$&#x27;s parent will extend our overall range leftward or rightward. In this case, the index of $[1, 1]$ will be odd, which means that merging in $[1, 2]$ will extend our range rightward.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;For example:&lt;&#x2F;p&gt;
&lt;p&gt;The parent of $[l, l]$ may include $[l - 1, l]$ or $[l, l + 1]$, depending on whether $l$ is even or odd.
We always want to move towards $[l, l + 1]$, since $l - 1$ is NOT in our range, but $l + 1$ &lt;em&gt;is&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;In the case that $[l, l]$&#x27;s parent is $[l - 1, l]$, we move up to $[l + 1, l + 2]$ and merge $[l, l]$ in.&lt;&#x2F;p&gt;
&lt;p&gt;Similarly, if $[r, r]$&#x27;s parent is $[r, r + 1]$, we move up to $[r - 2, r - 1]$ and merge $[r, r]$ in.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;small&gt;Keep in mind that $[l, r] \equiv \lbrace l, l + 1, l + 2, ..., r \rbrace$ &lt;&#x2F;small&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;


&lt;figure class=&quot;center size-medium&quot;&gt;&lt;!--Add proper accessibility to svgs: https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;4756461&#x2F;10147642 - if you&#x27;re reading this in DevTools, and have an idea of how to, feel free to write to me!--&gt;
	
	&lt;?xml version=&#x27;1.0&#x27; encoding=&#x27;UTF-8&#x27;?&gt;
&lt;!-- This file was generated by dvisvgm 3.2.2 --&gt;
&lt;svg version=&#x27;1.1&#x27; xmlns=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;2000&#x2F;svg&#x27; xmlns:xlink=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xlink&#x27;   viewBox=&#x27;154.429651 -.00025 159.140599 134.304966&#x27;&gt;
&lt;style type=&#x27;text&#x2F;css&#x27;&gt;
&lt;![CDATA[@font-face{font-family:cmr10;src:url(data:application&#x2F;x-font-ttf;base64,AAEAAAAKAIAAAwAgT1MvMoVLdCkAAACsAAAAYGNtYXAADACMAAABDAAAADRnbHlm14gP0wAAAUAAAAYUaGVhZCftHkUAAAdUAAAANmhoZWEFEAGSAAAHjAAAACRobXR4BZ0AzQAAB7AAAAAabG9jYQcUCJYAAAfMAAAAGG1heHAADwBAAAAH5AAAACBuYW1lguMqqQAACAQAAAE4cG9zdAADAAEAAAk8AAAAIAADAgsBkAAFAAACmgLN&#x2F;hQAjwKaAs0B7AHsADMBCQAAAAAGAAAAAAAAAAAAAAEAAAAAAAAAAAAAAABkc3ZnAAYAMAA5AwD&#x2F;AAAAAwABAAAAAAEAAAAAAAAAAAAA&#x2F;&#x2F;8AAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAIAAAAAQABAABAAAAOf&#x2F;&#x2F;AAAAMP&#x2F;&#x2F;&#x2F;9EAAQAAAAAAAgAn&#x2F;+cB2AKsABYALgAAARYGBw4BJwYmJy4BNDY3PgEXNhYXHgEDFjY3Ni8BJicuAQcmDwEGBwYfARYXHgEB1wEPGCRjKydfIx8QDxghYi8jZSYaENkkRg4OAwECBxJLHBYmBiYSCgIBAggQRwFIPXU2RzICASw9O4F4djVGNQECLUg5ef57ATlIYXNmNixJMQMEFgMYVlZmbDwwSTQAAAEAWwAAAa0CqwAYAAABEQYWOwEVJyMHNTMyNicRDgEnNRY2NzYWAS0DIEIhUapRIUMfAylMERxsMxEHAo&#x2F;9whwVIAMDIBUcAhITCAEfAhUvAQoAAAEAMwAAAc0CqgArAAA3Mzc2NzY&#x2F;ATMHITc2PwE+ATc0JiciBgc3HgEVDgEnBiYnPgE3HgEXFgcGB4K4NyIJBwYJGh3+hAECCMUsPwFERi1KEw0bHAIlDwUuAwFnWF94AgEzNnVPAQEGDRszshgHB9swdT1CYwI2MgEBIBQfGQECEylHbwMBbVlIPj9mAAAAAAEAK&#x2F;&#x2F;pAdQCqQA3AAABHgEXDgEHLgEnPgEXMhYUBiceAjY3NCYnIwY2FzcWPgInLgEHJgYHNhYXFAYjJic+ATIeAQYBKVFZAQJ5X1Z3AgElExghJxweXEhLAzs+LRoDDSgUMCsKAQI+Ih5RGQ4vAhwYMAQCZJxtAU4BaBFnQVFyAwFZRyIbAR45HgMsIwFFZk1cAQMcAQMBEkhFDEMwAQEbJQIQJRceATU7T019YQAAAgAdAAAB4gK4ABoAHQAAJSE1ATYXMhYHETMVIxUGFjsBFScjBzUzMjYnNxEDAS3+8AE6CQwMBQFmZgIZNxVFjEQVNxkCBvqpIAHgDwMLD&#x2F;4uIFkcFCADAyAUHHkBfv6CAAAAAAEAM&#x2F;&#x2F;pAcwCqgA9AAAlDgEHLgEnPgEXHgEUBgciJx4BFzY3PgEnNicuAScOAQcGIyI3ESYzNhcWNz4BPwEWFRQPAQYHJicVNhceAQHMA4BcV2IBAiQMGhoaGg4DDlA4SCYRCQEDFgYpKD0&#x2F;CAQJEgMCDQIKSj40SA8JCiwQM1c0IzhKVWzOZH4DBHJGIxQBAR4mHgECL0MBA0AhTh1LNhAwAgQ1DwkaAS8ZAQQfAgEVCAMBCg4nDCYEAgzINQEDfwAAAAACACv&#x2F;5gHUAqoAKAA8AAATPgE3HgEXDgEHBicmJyYnNj8BNjceARUOAS4BJz4BFy4BByYHBgcGBxMWNjc+ATQmJy4BBw4BFwYWFx4BhxA8NFd0AgJ5WEM+Dg03AwRNCVBjQEIBIB8dAQIpDRI0FCE0GBcsA3oSOxgNBgYOGTkNRDoBAQYOBDEBUCc8AgJ&#x2F;Y2h9AwM7DhNNtaReDFcBAT8vHRUBGBchDgEaEAEDHxMiP5j+ngIZLBxIS0ocLhQCBHNAEF0nDzsAAAEAOf&#x2F;pAfECtAAhAAABBw4BBwYdARYGBy4BNyY2PwIFBgcGDwEjNzMGFjsBBwYB54ohHAIMAQ4iIQ8BATtESCv++CcJCwYJGiIaASpa+QECAnDDMmkUU1U0CiwDAywKUMdqZT0BAQUMITDTDhMVBgADACv&#x2F;6QHVAqoACwApADUAABMXPgE3LgEiBgcGFh8BFhceAQcOAQcuASc+ATcnJicuATc+ATceARcOAQcOARceATI2Ny4BJ6d&#x2F;LzUBAlFxUQIBErdEFA4cFwECellUfQMEXzArFgkfDwECaE9JbAMBQp9AOQECXIZdAgIzGAHUUhtILDlFOS8NLnksDw4hQRxUbAMBX1JLXBUeDwolPg5JYAIBUEgzT0clWy1CUkc5LjQPAAACACv&#x2F;6QHUAq0AKQA+AAABDgEHLgEnNDY3Nhc2FxYXFhcOAQciJic+ARcyFhcWBgceATcWNzY3NjcHPgEnNCYnLgEnJgYHDgEXBhYXHgEBeBI&#x2F;L1hzAiIgQlRAPA8ONQMEl2ZCSwEBIA4RHQEBFiAWPw8qMQ4OLAN&#x2F;QjwBBwoNMSQcNRUQBwEBBg4ZOQFGLTkBAoBjOEwhQwIDNxAVTbOnvgM7NB4UARcYDiABGgwBAykOFT2ZLgNyQyVSGSMtAQEbJh1GKiZJHS4UAAABAAAAAQAAcpK4r18PPPUAAwQAAAAAAOMq7VUAAAAA4yrtVQAA&#x2F;+YCgAK4AAAACAACAAAAAAAAAAEAAAMA&#x2F;wAAAAKAAB0ADwHxAAEAAAAAAAAAAAAAAAAAAAACAoAAAAIAACcAWwAzACsAHQAzACsAOQArACsAAAAAAAAAUAB6AMIBGgFMAa4CEgJKAqQDCgABAAAACwA&#x2F;AAMAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgB+AAEAAAAAAAEADwAAAAEAAAAAAAQABQAPAAEAAAAAAAUACwAUAAEAAAAAAAYABQAfAAEAAAAAAAoAGgAkAAMAAQQJAAEAHgA+AAMAAQQJAAQACgBcAAMAAQQJAAUAFgBmAAMAAQQJAAYACgB8AAMAAQQJAAoANACGQ29tcHV0ZXIgTW9kZXJuY21yMTBWZXJzaW9uIDEuMGNtcjEwR2VuZXJhdGVkIGJ5IGR2aXN2Z20gMy4yLjIAQwBvAG0AcAB1AHQAZQByACAATQBvAGQAZQByAG4AYwBtAHIAMQAwAFYAZQByAHMAaQBvAG4AIAAxAC4AMABjAG0AcgAxADAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABkAHYAaQBzAHYAZwBtACAAMwAuADIALgAyAAMAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=) format(&#x27;truetype&#x27;);}
text.f0 {font-family:cmr10;font-size:9.96264px}
]]&gt;
&lt;&#x2F;style&gt;
&lt;g id=&#x27;page1&#x27;&gt;
&lt;path d=&#x27;M154.628901 134.105466V114.2617H273.687V134.105466Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M273.687 134.105466V114.2617H293.527V134.105466Z&#x27; fill=&#x27;var(--diagram-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M154.628901 134.105466H313.371M154.628901 114.2695H313.371M154.628901 134.105466V114.2617M174.4727 134.105466V114.2617M194.3164 134.105466V114.2617M214.1562 134.105466V114.2617M234 134.105466V114.2617M253.8437 134.105466V114.2617M273.687 134.105466V114.2617M293.527 134.105466V114.2617M313.363 134.105466V114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 7.431 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 27.273 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 47.116 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 66.959 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 86.801 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 106.644 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 126.487 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 146.329 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M183.2266 84.5C183.2266 79.6641 179.3086 75.7461 174.4727 75.7461C169.6367 75.7461 165.7187 79.6641 165.7187 84.5C165.7187 89.332 169.6367 93.2539 174.4727 93.2539C179.3086 93.2539 183.2266 89.332 183.2266 84.5Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M183.2266 84.5C183.2266 79.6641 179.3086 75.7461 174.4727 75.7461C169.6367 75.7461 165.7187 79.6641 165.7187 84.5C165.7187 89.332 169.6367 93.2539 174.4727 93.2539C179.3086 93.2539 183.2266 89.332 183.2266 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 17.352 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M171.6406 92.9922L164.55078 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M177.3047 92.9922L184.3945 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 84.5C222.9102 79.6641 218.9922 75.7461 214.1562 75.7461C209.3242 75.7461 205.4062 79.6641 205.4062 84.5C205.4062 89.332 209.3242 93.2539 214.1562 93.2539C218.9922 93.2539 222.9102 89.332 222.9102 84.5Z&#x27; fill=&#x27;var(--diagram-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 84.5C222.9102 79.6641 218.9922 75.7461 214.1562 75.7461C209.3242 75.7461 205.4062 79.6641 205.4062 84.5C205.4062 89.332 209.3242 93.2539 214.1562 93.2539C218.9922 93.2539 222.9102 89.332 222.9102 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 57.037 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M211.3281 92.9922L204.2383 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M216.9883 92.9922L224.0781 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.598 84.5C262.598 79.6641 258.676 75.7461 253.8437 75.7461C249.0078 75.7461 245.0898 79.6641 245.0898 84.5C245.0898 89.332 249.0078 93.2539 253.8437 93.2539C258.676 93.2539 262.598 89.332 262.598 84.5Z&#x27; fill=&#x27;var(--diagram-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.598 84.5C262.598 79.6641 258.676 75.7461 253.8437 75.7461C249.0078 75.7461 245.0898 79.6641 245.0898 84.5C245.0898 89.332 249.0078 93.2539 253.8437 93.2539C258.676 93.2539 262.598 89.332 262.598 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 96.723 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M251.0156 92.9922L243.9219 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M256.676 92.9922L263.766 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M302.281 84.5C302.281 79.6641 298.363 75.7461 293.527 75.7461C288.695 75.7461 284.777 79.6641 284.777 84.5C284.777 89.332 288.695 93.2539 293.527 93.2539C298.363 93.2539 302.281 89.332 302.281 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 136.408 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M290.699 92.9922L283.609 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M296.363 92.9922L303.449 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M168.4883 113.2695C168.4883 111.0977 166.7266 109.332 164.55078 109.332C162.375 109.332 160.61328 111.0977 160.61328 113.2695C160.61328 115.4453 162.375 117.2109 164.55078 117.2109C166.7266 117.2109 168.4883 115.4453 168.4883 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M168.4883 113.2695C168.4883 111.0977 166.7266 109.332 164.55078 109.332C162.375 109.332 160.61328 111.0977 160.61328 113.2695C160.61328 115.4453 162.375 117.2109 164.55078 117.2109C166.7266 117.2109 168.4883 115.4453 168.4883 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 93.8475 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.332 113.2695C188.332 111.0977 186.5703 109.332 184.3945 109.332S180.457 111.0977 180.457 113.2695C180.457 115.4453 182.2187 117.2109 184.3945 117.2109S188.332 115.4453 188.332 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M188.332 113.2695C188.332 111.0977 186.5703 109.332 184.3945 109.332S180.457 111.0977 180.457 113.2695C180.457 115.4453 182.2187 117.2109 184.3945 117.2109S188.332 115.4453 188.332 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 113.6895 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M208.9961 113.2695C208.9961 110.6445 206.8633 108.5117 204.2383 108.5117C201.6094 108.5117 199.4805 110.6445 199.4805 113.2695C199.4805 115.8984 201.6094 118.0273 204.2383 118.0273C206.8633 118.0273 208.9961 115.8984 208.9961 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M208.9961 113.2695C208.9961 110.6445 206.8633 108.5117 204.2383 108.5117C201.6094 108.5117 199.4805 110.6445 199.4805 113.2695C199.4805 115.8984 201.6094 118.0273 204.2383 118.0273C206.8633 118.0273 208.9961 115.8984 208.9961 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 132.4115 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;10&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M228.8359 113.2695C228.8359 110.6445 226.707 108.5117 224.0781 108.5117C221.4531 108.5117 219.3203 110.6445 219.3203 113.2695C219.3203 115.8984 221.4531 118.0273 224.0781 118.0273C226.707 118.0273 228.8359 115.8984 228.8359 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M228.8359 113.2695C228.8359 110.6445 226.707 108.5117 224.0781 108.5117C221.4531 108.5117 219.3203 110.6445 219.3203 113.2695C219.3203 115.8984 221.4531 118.0273 224.0781 118.0273C226.707 118.0273 228.8359 115.8984 228.8359 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 152.2545 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;11&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M248.6797 113.2695C248.6797 110.6445 246.5508 108.5117 243.9219 108.5117S239.1641 110.6445 239.1641 113.2695C239.1641 115.8984 241.293 118.0273 243.9219 118.0273S248.6797 115.8984 248.6797 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M248.6797 113.2695C248.6797 110.6445 246.5508 108.5117 243.9219 108.5117S239.1641 110.6445 239.1641 113.2695C239.1641 115.8984 241.293 118.0273 243.9219 118.0273S248.6797 115.8984 248.6797 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 172.0965 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;12&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M268.523 113.2695C268.523 110.6445 266.395 108.5117 263.766 108.5117S259.008 110.6445 259.008 113.2695C259.008 115.8984 261.137 118.0273 263.766 118.0273S268.523 115.8984 268.523 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M268.523 113.2695C268.523 110.6445 266.395 108.5117 263.766 108.5117S259.008 110.6445 259.008 113.2695C259.008 115.8984 261.137 118.0273 263.766 118.0273S268.523 115.8984 268.523 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 191.9395 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;13&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M288.367 113.2695C288.367 110.6445 286.234 108.5117 283.609 108.5117C280.98 108.5117 278.848 110.6445 278.848 113.2695C278.848 115.8984 280.98 118.0273 283.609 118.0273C286.234 118.0273 288.367 115.8984 288.367 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M288.367 113.2695C288.367 110.6445 286.234 108.5117 283.609 108.5117C280.98 108.5117 278.848 110.6445 278.848 113.2695C278.848 115.8984 280.98 118.0273 283.609 118.0273C286.234 118.0273 288.367 115.8984 288.367 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 211.7825 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;14&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M308.207 113.2695C308.207 110.6445 306.078 108.5117 303.449 108.5117C300.824 108.5117 298.691 110.6445 298.691 113.2695C298.691 115.8984 300.824 118.0273 303.449 118.0273C306.078 118.0273 308.207 115.8984 308.207 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M308.207 113.2695C308.207 110.6445 306.078 108.5117 303.449 108.5117C300.824 108.5117 298.691 110.6445 298.691 113.2695C298.691 115.8984 300.824 118.0273 303.449 118.0273C306.078 118.0273 308.207 115.8984 308.207 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 231.6245 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;15&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M204.8203 54.7344C204.8203 48.9336 200.1172 44.2305 194.3164 44.2305S183.8125 48.9336 183.8125 54.7344S188.5156 65.2383 194.3164 65.2383S204.8203 60.5352 204.8203 54.7344Z&#x27; fill=&#x27;var(--diagram-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M204.8203 54.7344C204.8203 48.9336 200.1172 44.2305 194.3164 44.2305S183.8125 48.9336 183.8125 54.7344S188.5156 65.2383 194.3164 65.2383S204.8203 60.5352 204.8203 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 5.771 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.3555 63.6719L179.4375 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M200.2773 63.6719L209.1953 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M284.191 54.7344C284.191 48.9336 279.488 44.2305 273.687 44.2305C267.887 44.2305 263.184 48.9336 263.184 54.7344S267.887 65.2383 273.687 65.2383C279.488 65.2383 284.191 60.5352 284.191 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 85.141 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M267.73 63.6719L258.812 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M279.648 63.6719L288.566 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M165.8633 109.4609C162.39062 102.7266 164.668 96.1289 168.2344 92.4961&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M165.663666 92.152348C166.30819 92.605471 168.140213 92.40626 168.503498 92.218753C168.32381 92.585947 168.159754 94.417973 168.620679 95.054689&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.637559&#x27; stroke-miterlimit=&#x27;10&#x27; stroke-linecap=&#x27;round&#x27; stroke-linejoin=&#x27;round&#x27;&#x2F;&gt;
&lt;path d=&#x27;M179.4375 77.0508C177.5547 70 181.1211 64.6484 185.25 62.3633&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M182.887039 61.304686C183.375324 61.917959 185.187818 62.249997 185.590157 62.171871C185.312822 62.476552 184.629233 64.183585 184.894849 64.929678&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.637582&#x27; stroke-miterlimit=&#x27;10&#x27; stroke-linecap=&#x27;round&#x27; stroke-linejoin=&#x27;round&#x27;&#x2F;&gt;
&lt;path d=&#x27;M278.762 113.2695C275.719 107.793 271.66 107.793 269.16 109.8359&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M271.675797 110.453094C271.085951 109.933569 269.242195 109.93357 268.859377 110.078092C269.078127 109.734344 269.445315 107.929646 269.050787 107.246065&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.637561&#x27; stroke-miterlimit=&#x27;10&#x27; stroke-linecap=&#x27;round&#x27; stroke-linejoin=&#x27;round&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.187 108.6875C265.742 102.1836 263.57 95.8945 260.094 92.4844&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M259.753655 95.050763C260.206777 94.406243 260.003656 92.578109 259.816161 92.210935C260.187253 92.390606 262.019274 92.558588 262.656006 92.093743&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.637565&#x27; stroke-miterlimit=&#x27;10&#x27; stroke-linecap=&#x27;round&#x27; stroke-linejoin=&#x27;round&#x27;&#x2F;&gt;
&lt;path d=&#x27;M244.8945 84.5C238.3594 79.0195 229.6445 79.0195 223.7734 81.2578&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M225.961253 82.640584C225.566716 81.960888 223.820626 81.378857 223.410473 81.394486C223.72688 81.136667 224.644837 79.539015 224.488591 78.769485&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.637579&#x27; stroke-miterlimit=&#x27;10&#x27; stroke-linecap=&#x27;round&#x27; stroke-linejoin=&#x27;round&#x27;&#x2F;&gt;
&lt;path d=&#x27;M209.1953 77.0508C211.0781 69.9961 207.5117 64.6484 203.3828 62.3633&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M203.738267 64.925748C204.0039 64.18356 203.320304 62.476533 203.042959 62.17184C203.445311 62.249969 205.257808 61.917933 205.746084 61.300758&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.637587&#x27; stroke-miterlimit=&#x27;10&#x27; stroke-linecap=&#x27;round&#x27; stroke-linejoin=&#x27;round&#x27;&#x2F;&gt;
&lt;path d=&#x27;M178.4102 75.5703C178.4102 73.3945 176.6484 71.6328 174.4727 71.6328C172.2969 71.6328 170.5352 73.3945 170.5352 75.5703S172.2969 79.5078 174.4727 79.5078C176.6484 79.5078 178.4102 77.7461 178.4102 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M178.4102 75.5703C178.4102 73.3945 176.6484 71.6328 174.4727 71.6328C172.2969 71.6328 170.5352 73.3945 170.5352 75.5703S172.2969 79.5078 174.4727 79.5078C176.6484 79.5078 178.4102 77.7461 178.4102 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 103.7685 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M218.0977 75.5703C218.0977 73.3945 216.332 71.6328 214.1562 71.6328C211.9844 71.6328 210.2187 73.3945 210.2187 75.5703S211.9844 79.5078 214.1562 79.5078C216.332 79.5078 218.0977 77.7461 218.0977 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M218.0977 75.5703C218.0977 73.3945 216.332 71.6328 214.1562 71.6328C211.9844 71.6328 210.2187 73.3945 210.2187 75.5703S211.9844 79.5078 214.1562 79.5078C216.332 79.5078 218.0977 77.7461 218.0977 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 143.4535 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M257.781 75.5703C257.781 73.3945 256.02 71.6328 253.8437 71.6328C251.668 71.6328 249.9062 73.3945 249.9062 75.5703S251.668 79.5078 253.8437 79.5078C256.02 79.5078 257.781 77.7461 257.781 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M257.781 75.5703C257.781 73.3945 256.02 71.6328 253.8437 71.6328C251.668 71.6328 249.9062 73.3945 249.9062 75.5703S251.668 79.5078 253.8437 79.5078C256.02 79.5078 257.781 77.7461 257.781 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 183.1395 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;6&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M297.469 75.5703C297.469 73.3945 295.703 71.6328 293.527 71.6328C291.352 71.6328 289.59 73.3945 289.59 75.5703S291.352 79.5078 293.527 79.5078C295.703 79.5078 297.469 77.7461 297.469 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M297.469 75.5703C297.469 73.3945 295.703 71.6328 293.527 71.6328C291.352 71.6328 289.59 73.3945 289.59 75.5703S291.352 79.5078 293.527 79.5078C295.703 79.5078 297.469 77.7461 297.469 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 222.8245 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;7&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M244.9414 15.051C244.9414 9.008 240.043 4.109 234 4.109S223.0586 9.008 223.0586 15.051S227.957 25.992 234 25.992S244.9414 21.094 244.9414 15.051Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.25 0 0 1.25 37.5995 -148.5698)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M226.0898 22.961L201.9141 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M241.9141 22.961L266.094 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M198.2539 43.8203C198.2539 41.6445 196.4922 39.8828 194.3164 39.8828S190.375 41.6445 190.375 43.8203S192.1406 47.7617 194.3164 47.7617S198.2539 45.9961 198.2539 43.8203Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M198.2539 43.8203C198.2539 41.6445 196.4922 39.8828 194.3164 39.8828S190.375 41.6445 190.375 43.8203S192.1406 47.7617 194.3164 47.7617S198.2539 45.9961 198.2539 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 123.6115 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M277.625 43.8203C277.625 41.6445 275.863 39.8828 273.687 39.8828C271.512 39.8828 269.746 41.6445 269.746 43.8203S271.512 47.7617 273.687 47.7617C275.863 47.7617 277.625 45.9961 277.625 43.8203Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M277.625 43.8203C277.625 41.6445 275.863 39.8828 273.687 39.8828C271.512 39.8828 269.746 41.6445 269.746 43.8203S271.512 47.7617 273.687 47.7617C275.863 47.7617 277.625 45.9961 277.625 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 202.9815 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M237.9414 4.137C237.9414 1.961 236.1758 .199 234 .199S230.0625 1.961 230.0625 4.137C230.0625 6.312 231.8242 8.074 234 8.074S237.9414 6.312 237.9414 4.137Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M237.9414 4.137C237.9414 1.961 236.1758 .199 234 .199S230.0625 1.961 230.0625 4.137C230.0625 6.312 231.8242 8.074 234 8.074S237.9414 6.312 237.9414 4.137Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 163.2965 -54.76671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;svg&gt;

	
		&lt;figcaption  style=&quot;font-style: italic;&quot;&gt;Querying $[1, 7]$&lt;&#x2F;figcaption&gt;
	

&lt;&#x2F;figure&gt;

	&lt;small&gt;&lt;span class=&quot;codeblock-name&quot;&gt;&lt;a href = &quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;competitive-programming&#x2F;dsa-explanations&#x2F;basic-segment-tree&#x2F;code&#x2F;segtree-two-power&#x2F;src&#x2F;max_segtree.rs&quot;&gt;code&amp;#x2F;segtree-two-power&amp;#x2F;src&amp;#x2F;max_segtree.rs&lt;&#x2F;a&gt;&lt;&#x2F;span&gt;&lt;&#x2F;small&gt;
&lt;pre data-linenos data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;31&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;query&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;self&lt;&#x2F;span&gt;, &lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;mut&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;l&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;mut&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;r&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;usize&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;usize&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;span class=&quot;z-meta z-function z-return-type z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;32&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        l &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;+=&lt;&#x2F;span&gt; N &lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;-&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt; r &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;+=&lt;&#x2F;span&gt; N &lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;-&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;33&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;let&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;mut&lt;&#x2F;span&gt; ans &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;l&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;34&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;while&lt;&#x2F;span&gt; l &lt;span class=&quot;z-keyword z-operator z-comparison z-rust&quot;&gt;&amp;lt;=&lt;&#x2F;span&gt; r &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;35&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;if&lt;&#x2F;span&gt; l &lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;%&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-comparison z-rust&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;1&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;36&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;                ans &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;max&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;ans&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;l&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt; l &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;+=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;37&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;38&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;if&lt;&#x2F;span&gt; r &lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;%&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-comparison z-rust&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;0&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;39&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;                ans &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;max&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;ans&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;r&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt; r &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;-=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;40&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;41&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            l &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;&#x2F;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt; r &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;&#x2F;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;42&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;43&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        ans
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;44&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;updating-update&quot;&gt;Updating &lt;code&gt;update&lt;&#x2F;code&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#updating-update&quot; aria-label=&quot;Anchor link for: updating-update&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Updating is straightforward - we start at $[i, i]$, then divide the index by half to move up a level and update &lt;em&gt;that&lt;&#x2F;em&gt; range. Repeat until all ranges which include $i$ have been updated.&lt;&#x2F;p&gt;


&lt;figure class=&quot;center size-medium&quot;&gt;&lt;!--Add proper accessibility to svgs: https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;4756461&#x2F;10147642 - if you&#x27;re reading this in DevTools, and have an idea of how to, feel free to write to me!--&gt;
	
	&lt;?xml version=&#x27;1.0&#x27; encoding=&#x27;UTF-8&#x27;?&gt;
&lt;!-- This file was generated by dvisvgm 3.2.2 --&gt;
&lt;svg version=&#x27;1.1&#x27; xmlns=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;2000&#x2F;svg&#x27; xmlns:xlink=&#x27;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xlink&#x27;   viewBox=&#x27;154.429651 -.00025 159.140599 134.304966&#x27;&gt;
&lt;style type=&#x27;text&#x2F;css&#x27;&gt;
&lt;![CDATA[@font-face{font-family:cmr10;src:url(data:application&#x2F;x-font-ttf;base64,AAEAAAAKAIAAAwAgT1MvMoVLdCkAAACsAAAAYGNtYXAADACMAAABDAAAADRnbHlm14gP0wAAAUAAAAYUaGVhZCftHkUAAAdUAAAANmhoZWEFEAGSAAAHjAAAACRobXR4BZ0AzQAAB7AAAAAabG9jYQcUCJYAAAfMAAAAGG1heHAADwBAAAAH5AAAACBuYW1lguMqqQAACAQAAAE4cG9zdAADAAEAAAk8AAAAIAADAgsBkAAFAAACmgLN&#x2F;hQAjwKaAs0B7AHsADMBCQAAAAAGAAAAAAAAAAAAAAEAAAAAAAAAAAAAAABkc3ZnAAYAMAA5AwD&#x2F;AAAAAwABAAAAAAEAAAAAAAAAAAAA&#x2F;&#x2F;8AAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAIAAAAAQABAABAAAAOf&#x2F;&#x2F;AAAAMP&#x2F;&#x2F;&#x2F;9EAAQAAAAAAAgAn&#x2F;+cB2AKsABYALgAAARYGBw4BJwYmJy4BNDY3PgEXNhYXHgEDFjY3Ni8BJicuAQcmDwEGBwYfARYXHgEB1wEPGCRjKydfIx8QDxghYi8jZSYaENkkRg4OAwECBxJLHBYmBiYSCgIBAggQRwFIPXU2RzICASw9O4F4djVGNQECLUg5ef57ATlIYXNmNixJMQMEFgMYVlZmbDwwSTQAAAEAWwAAAa0CqwAYAAABEQYWOwEVJyMHNTMyNicRDgEnNRY2NzYWAS0DIEIhUapRIUMfAylMERxsMxEHAo&#x2F;9whwVIAMDIBUcAhITCAEfAhUvAQoAAAEAMwAAAc0CqgArAAA3Mzc2NzY&#x2F;ATMHITc2PwE+ATc0JiciBgc3HgEVDgEnBiYnPgE3HgEXFgcGB4K4NyIJBwYJGh3+hAECCMUsPwFERi1KEw0bHAIlDwUuAwFnWF94AgEzNnVPAQEGDRszshgHB9swdT1CYwI2MgEBIBQfGQECEylHbwMBbVlIPj9mAAAAAAEAK&#x2F;&#x2F;pAdQCqQA3AAABHgEXDgEHLgEnPgEXMhYUBiceAjY3NCYnIwY2FzcWPgInLgEHJgYHNhYXFAYjJic+ATIeAQYBKVFZAQJ5X1Z3AgElExghJxweXEhLAzs+LRoDDSgUMCsKAQI+Ih5RGQ4vAhwYMAQCZJxtAU4BaBFnQVFyAwFZRyIbAR45HgMsIwFFZk1cAQMcAQMBEkhFDEMwAQEbJQIQJRceATU7T019YQAAAgAdAAAB4gK4ABoAHQAAJSE1ATYXMhYHETMVIxUGFjsBFScjBzUzMjYnNxEDAS3+8AE6CQwMBQFmZgIZNxVFjEQVNxkCBvqpIAHgDwMLD&#x2F;4uIFkcFCADAyAUHHkBfv6CAAAAAAEAM&#x2F;&#x2F;pAcwCqgA9AAAlDgEHLgEnPgEXHgEUBgciJx4BFzY3PgEnNicuAScOAQcGIyI3ESYzNhcWNz4BPwEWFRQPAQYHJicVNhceAQHMA4BcV2IBAiQMGhoaGg4DDlA4SCYRCQEDFgYpKD0&#x2F;CAQJEgMCDQIKSj40SA8JCiwQM1c0IzhKVWzOZH4DBHJGIxQBAR4mHgECL0MBA0AhTh1LNhAwAgQ1DwkaAS8ZAQQfAgEVCAMBCg4nDCYEAgzINQEDfwAAAAACACv&#x2F;5gHUAqoAKAA8AAATPgE3HgEXDgEHBicmJyYnNj8BNjceARUOAS4BJz4BFy4BByYHBgcGBxMWNjc+ATQmJy4BBw4BFwYWFx4BhxA8NFd0AgJ5WEM+Dg03AwRNCVBjQEIBIB8dAQIpDRI0FCE0GBcsA3oSOxgNBgYOGTkNRDoBAQYOBDEBUCc8AgJ&#x2F;Y2h9AwM7DhNNtaReDFcBAT8vHRUBGBchDgEaEAEDHxMiP5j+ngIZLBxIS0ocLhQCBHNAEF0nDzsAAAEAOf&#x2F;pAfECtAAhAAABBw4BBwYdARYGBy4BNyY2PwIFBgcGDwEjNzMGFjsBBwYB54ohHAIMAQ4iIQ8BATtESCv++CcJCwYJGiIaASpa+QECAnDDMmkUU1U0CiwDAywKUMdqZT0BAQUMITDTDhMVBgADACv&#x2F;6QHVAqoACwApADUAABMXPgE3LgEiBgcGFh8BFhceAQcOAQcuASc+ATcnJicuATc+ATceARcOAQcOARceATI2Ny4BJ6d&#x2F;LzUBAlFxUQIBErdEFA4cFwECellUfQMEXzArFgkfDwECaE9JbAMBQp9AOQECXIZdAgIzGAHUUhtILDlFOS8NLnksDw4hQRxUbAMBX1JLXBUeDwolPg5JYAIBUEgzT0clWy1CUkc5LjQPAAACACv&#x2F;6QHUAq0AKQA+AAABDgEHLgEnNDY3Nhc2FxYXFhcOAQciJic+ARcyFhcWBgceATcWNzY3NjcHPgEnNCYnLgEnJgYHDgEXBhYXHgEBeBI&#x2F;L1hzAiIgQlRAPA8ONQMEl2ZCSwEBIA4RHQEBFiAWPw8qMQ4OLAN&#x2F;QjwBBwoNMSQcNRUQBwEBBg4ZOQFGLTkBAoBjOEwhQwIDNxAVTbOnvgM7NB4UARcYDiABGgwBAykOFT2ZLgNyQyVSGSMtAQEbJh1GKiZJHS4UAAABAAAAAQAAcpK4r18PPPUAAwQAAAAAAOMq7VUAAAAA4yrtVQAA&#x2F;+YCgAK4AAAACAACAAAAAAAAAAEAAAMA&#x2F;wAAAAKAAB0ADwHxAAEAAAAAAAAAAAAAAAAAAAACAoAAAAIAACcAWwAzACsAHQAzACsAOQArACsAAAAAAAAAUAB6AMIBGgFMAa4CEgJKAqQDCgABAAAACwA&#x2F;AAMAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgB+AAEAAAAAAAEADwAAAAEAAAAAAAQABQAPAAEAAAAAAAUACwAUAAEAAAAAAAYABQAfAAEAAAAAAAoAGgAkAAMAAQQJAAEAHgA+AAMAAQQJAAQACgBcAAMAAQQJAAUAFgBmAAMAAQQJAAYACgB8AAMAAQQJAAoANACGQ29tcHV0ZXIgTW9kZXJuY21yMTBWZXJzaW9uIDEuMGNtcjEwR2VuZXJhdGVkIGJ5IGR2aXN2Z20gMy4yLjIAQwBvAG0AcAB1AHQAZQByACAATQBvAGQAZQByAG4AYwBtAHIAMQAwAFYAZQByAHMAaQBvAG4AIAAxAC4AMABjAG0AcgAxADAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABkAHYAaQBzAHYAZwBtACAAMwAuADIALgAyAAMAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=) format(&#x27;truetype&#x27;);}
text.f0 {font-family:cmr10;font-size:9.96264px}
]]&gt;
&lt;&#x2F;style&gt;
&lt;g id=&#x27;page1&#x27;&gt;
&lt;path d=&#x27;M194.3164 134.105466V114.2617H214.1562V134.105466Z&#x27; fill=&#x27;var(--diagram-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M154.628901 134.105466H313.371M154.628901 114.2695H313.371M154.628901 134.105466V114.2617M174.4727 134.105466V114.2617M194.3164 134.105466V114.2617M214.1562 134.105466V114.2617M234 134.105466V114.2617M253.8437 134.105466V114.2617M273.687 134.105466V114.2617M293.527 134.105466V114.2617M313.363 134.105466V114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 7.431 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 27.273 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 47.116 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 66.959 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 86.801 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 106.644 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 126.487 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 146.329 -6.711)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M183.2266 84.5C183.2266 79.6641 179.3086 75.7461 174.4727 75.7461C169.6367 75.7461 165.7187 79.6641 165.7187 84.5C165.7187 89.332 169.6367 93.2539 174.4727 93.2539C179.3086 93.2539 183.2266 89.332 183.2266 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 17.352 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M171.6406 92.9922L164.55078 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M177.3047 92.9922L184.3945 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 84.5C222.9102 79.6641 218.9922 75.7461 214.1562 75.7461C209.3242 75.7461 205.4062 79.6641 205.4062 84.5C205.4062 89.332 209.3242 93.2539 214.1562 93.2539C218.9922 93.2539 222.9102 89.332 222.9102 84.5Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M222.9102 84.5C222.9102 79.6641 218.9922 75.7461 214.1562 75.7461C209.3242 75.7461 205.4062 79.6641 205.4062 84.5C205.4062 89.332 209.3242 93.2539 214.1562 93.2539C218.9922 93.2539 222.9102 89.332 222.9102 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 57.037 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M211.3281 92.9922L204.2383 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M216.9883 92.9922L224.0781 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M262.598 84.5C262.598 79.6641 258.676 75.7461 253.8437 75.7461C249.0078 75.7461 245.0898 79.6641 245.0898 84.5C245.0898 89.332 249.0078 93.2539 253.8437 93.2539C258.676 93.2539 262.598 89.332 262.598 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 96.723 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M251.0156 92.9922L243.9219 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M256.676 92.9922L263.766 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M302.281 84.5C302.281 79.6641 298.363 75.7461 293.527 75.7461C288.695 75.7461 284.777 79.6641 284.777 84.5C284.777 89.332 288.695 93.2539 293.527 93.2539C298.363 93.2539 302.281 89.332 302.281 84.5Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1 0 0 1 136.408 -46.3965)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M290.699 92.9922L283.609 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M296.363 92.9922L303.449 114.2617&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M168.4883 113.2695C168.4883 111.0977 166.7266 109.332 164.55078 109.332C162.375 109.332 160.61328 111.0977 160.61328 113.2695C160.61328 115.4453 162.375 117.2109 164.55078 117.2109C166.7266 117.2109 168.4883 115.4453 168.4883 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M168.4883 113.2695C168.4883 111.0977 166.7266 109.332 164.55078 109.332C162.375 109.332 160.61328 111.0977 160.61328 113.2695C160.61328 115.4453 162.375 117.2109 164.55078 117.2109C166.7266 117.2109 168.4883 115.4453 168.4883 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 93.8475 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;8&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.332 113.2695C188.332 111.0977 186.5703 109.332 184.3945 109.332S180.457 111.0977 180.457 113.2695C180.457 115.4453 182.2187 117.2109 184.3945 117.2109S188.332 115.4453 188.332 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M188.332 113.2695C188.332 111.0977 186.5703 109.332 184.3945 109.332S180.457 111.0977 180.457 113.2695C180.457 115.4453 182.2187 117.2109 184.3945 117.2109S188.332 115.4453 188.332 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 113.6895 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M208.9961 113.2695C208.9961 110.6445 206.8633 108.5117 204.2383 108.5117C201.6094 108.5117 199.4805 110.6445 199.4805 113.2695C199.4805 115.8984 201.6094 118.0273 204.2383 118.0273C206.8633 118.0273 208.9961 115.8984 208.9961 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M208.9961 113.2695C208.9961 110.6445 206.8633 108.5117 204.2383 108.5117C201.6094 108.5117 199.4805 110.6445 199.4805 113.2695C199.4805 115.8984 201.6094 118.0273 204.2383 118.0273C206.8633 118.0273 208.9961 115.8984 208.9961 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 132.4115 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;10&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M228.8359 113.2695C228.8359 110.6445 226.707 108.5117 224.0781 108.5117C221.4531 108.5117 219.3203 110.6445 219.3203 113.2695C219.3203 115.8984 221.4531 118.0273 224.0781 118.0273C226.707 118.0273 228.8359 115.8984 228.8359 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M228.8359 113.2695C228.8359 110.6445 226.707 108.5117 224.0781 108.5117C221.4531 108.5117 219.3203 110.6445 219.3203 113.2695C219.3203 115.8984 221.4531 118.0273 224.0781 118.0273C226.707 118.0273 228.8359 115.8984 228.8359 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 152.2545 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;11&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M248.6797 113.2695C248.6797 110.6445 246.5508 108.5117 243.9219 108.5117S239.1641 110.6445 239.1641 113.2695C239.1641 115.8984 241.293 118.0273 243.9219 118.0273S248.6797 115.8984 248.6797 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M248.6797 113.2695C248.6797 110.6445 246.5508 108.5117 243.9219 108.5117S239.1641 110.6445 239.1641 113.2695C239.1641 115.8984 241.293 118.0273 243.9219 118.0273S248.6797 115.8984 248.6797 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 172.0965 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;12&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M268.523 113.2695C268.523 110.6445 266.395 108.5117 263.766 108.5117S259.008 110.6445 259.008 113.2695C259.008 115.8984 261.137 118.0273 263.766 118.0273S268.523 115.8984 268.523 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M268.523 113.2695C268.523 110.6445 266.395 108.5117 263.766 108.5117S259.008 110.6445 259.008 113.2695C259.008 115.8984 261.137 118.0273 263.766 118.0273S268.523 115.8984 268.523 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 191.9395 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;13&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M288.367 113.2695C288.367 110.6445 286.234 108.5117 283.609 108.5117C280.98 108.5117 278.848 110.6445 278.848 113.2695C278.848 115.8984 280.98 118.0273 283.609 118.0273C286.234 118.0273 288.367 115.8984 288.367 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M288.367 113.2695C288.367 110.6445 286.234 108.5117 283.609 108.5117C280.98 108.5117 278.848 110.6445 278.848 113.2695C278.848 115.8984 280.98 118.0273 283.609 118.0273C286.234 118.0273 288.367 115.8984 288.367 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 211.7825 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;14&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M308.207 113.2695C308.207 110.6445 306.078 108.5117 303.449 108.5117C300.824 108.5117 298.691 110.6445 298.691 113.2695C298.691 115.8984 300.824 118.0273 303.449 118.0273C306.078 118.0273 308.207 115.8984 308.207 113.2695Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M308.207 113.2695C308.207 110.6445 306.078 108.5117 303.449 108.5117C300.824 108.5117 298.691 110.6445 298.691 113.2695C298.691 115.8984 300.824 118.0273 303.449 118.0273C306.078 118.0273 308.207 115.8984 308.207 113.2695Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 231.6245 54.3683)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;15&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M204.8203 54.7344C204.8203 48.9336 200.1172 44.2305 194.3164 44.2305S183.8125 48.9336 183.8125 54.7344S188.5156 65.2383 194.3164 65.2383S204.8203 60.5352 204.8203 54.7344Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M204.8203 54.7344C204.8203 48.9336 200.1172 44.2305 194.3164 44.2305S183.8125 48.9336 183.8125 54.7344S188.5156 65.2383 194.3164 65.2383S204.8203 60.5352 204.8203 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 5.771 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M188.3555 63.6719L179.4375 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M200.2773 63.6719L209.1953 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M284.191 54.7344C284.191 48.9336 279.488 44.2305 273.687 44.2305C267.887 44.2305 263.184 48.9336 263.184 54.7344S267.887 65.2383 273.687 65.2383C279.488 65.2383 284.191 60.5352 284.191 54.7344Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.2 0 0 1.2 85.141 -102.3397)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M267.73 63.6719L258.812 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M279.648 63.6719L288.566 77.0508&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M178.4102 75.5703C178.4102 73.3945 176.6484 71.6328 174.4727 71.6328C172.2969 71.6328 170.5352 73.3945 170.5352 75.5703S172.2969 79.5078 174.4727 79.5078C176.6484 79.5078 178.4102 77.7461 178.4102 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M178.4102 75.5703C178.4102 73.3945 176.6484 71.6328 174.4727 71.6328C172.2969 71.6328 170.5352 73.3945 170.5352 75.5703S172.2969 79.5078 174.4727 79.5078C176.6484 79.5078 178.4102 77.7461 178.4102 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 103.7685 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;4&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M218.0977 75.5703C218.0977 73.3945 216.332 71.6328 214.1562 71.6328C211.9844 71.6328 210.2187 73.3945 210.2187 75.5703S211.9844 79.5078 214.1562 79.5078C216.332 79.5078 218.0977 77.7461 218.0977 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M218.0977 75.5703C218.0977 73.3945 216.332 71.6328 214.1562 71.6328C211.9844 71.6328 210.2187 73.3945 210.2187 75.5703S211.9844 79.5078 214.1562 79.5078C216.332 79.5078 218.0977 77.7461 218.0977 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 143.4535 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;5&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M257.781 75.5703C257.781 73.3945 256.02 71.6328 253.8437 71.6328C251.668 71.6328 249.9062 73.3945 249.9062 75.5703S251.668 79.5078 253.8437 79.5078C256.02 79.5078 257.781 77.7461 257.781 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M257.781 75.5703C257.781 73.3945 256.02 71.6328 253.8437 71.6328C251.668 71.6328 249.9062 73.3945 249.9062 75.5703S251.668 79.5078 253.8437 79.5078C256.02 79.5078 257.781 77.7461 257.781 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 183.1395 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;6&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M297.469 75.5703C297.469 73.3945 295.703 71.6328 293.527 71.6328C291.352 71.6328 289.59 73.3945 289.59 75.5703S291.352 79.5078 293.527 79.5078C295.703 79.5078 297.469 77.7461 297.469 75.5703Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M297.469 75.5703C297.469 73.3945 295.703 71.6328 293.527 71.6328C291.352 71.6328 289.59 73.3945 289.59 75.5703S291.352 79.5078 293.527 79.5078C295.703 79.5078 297.469 77.7461 297.469 75.5703Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 222.8245 16.6671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;7&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M244.9414 15.051C244.9414 9.008 240.043 4.109 234 4.109S223.0586 9.008 223.0586 15.051S227.957 25.992 234 25.992S244.9414 21.094 244.9414 15.051Z&#x27; fill=&#x27;var(--diagram-secondary-highlight)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M244.9414 15.051C244.9414 9.008 240.043 4.109 234 4.109S223.0586 9.008 223.0586 15.051S227.957 25.992 234 25.992S244.9414 21.094 244.9414 15.051Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(1.25 0 0 1.25 37.5995 -148.5698)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;9&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M226.0898 22.961L201.9141 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M241.9141 22.961L266.094 47.1367&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.79701&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;path d=&#x27;M198.2539 43.8203C198.2539 41.6445 196.4922 39.8828 194.3164 39.8828S190.375 41.6445 190.375 43.8203S192.1406 47.7617 194.3164 47.7617S198.2539 45.9961 198.2539 43.8203Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M198.2539 43.8203C198.2539 41.6445 196.4922 39.8828 194.3164 39.8828S190.375 41.6445 190.375 43.8203S192.1406 47.7617 194.3164 47.7617S198.2539 45.9961 198.2539 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 123.6115 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;2&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M277.625 43.8203C277.625 41.6445 275.863 39.8828 273.687 39.8828C271.512 39.8828 269.746 41.6445 269.746 43.8203S271.512 47.7617 273.687 47.7617C275.863 47.7617 277.625 45.9961 277.625 43.8203Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M277.625 43.8203C277.625 41.6445 275.863 39.8828 273.687 39.8828C271.512 39.8828 269.746 41.6445 269.746 43.8203S271.512 47.7617 273.687 47.7617C275.863 47.7617 277.625 45.9961 277.625 43.8203Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 202.9815 -15.0814)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;3&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;path d=&#x27;M237.9414 4.137C237.9414 1.961 236.1758 .199 234 .199S230.0625 1.961 230.0625 4.137C230.0625 6.312 231.8242 8.074 234 8.074S237.9414 6.312 237.9414 4.137Z&#x27; fill=&#x27;var(--diagram-background)&#x27;&#x2F;&gt;
&lt;path d=&#x27;M237.9414 4.137C237.9414 1.961 236.1758 .199 234 .199S230.0625 1.961 230.0625 4.137C230.0625 6.312 231.8242 8.074 234 8.074S237.9414 6.312 237.9414 4.137Z&#x27; stroke=&#x27;var(--diagram-frontmatter)&#x27; fill=&#x27;none&#x27; stroke-width=&#x27;.3985&#x27; stroke-miterlimit=&#x27;10&#x27;&#x2F;&gt;
&lt;text class=&#x27;f0&#x27; x=&#x27;154.630311&#x27; y=&#x27;134.10602&#x27; transform=&#x27;matrix(.45 0 0 .45 163.2965 -54.76671)&#x27;&gt;&lt;tspan fill=&#x27;var(--diagram-frontmatter)&#x27;&gt;1&lt;&#x2F;tspan&gt;&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;svg&gt;

	
		&lt;figcaption  style=&quot;font-style: italic;&quot;&gt;Setting $[3] = 9$&lt;&#x2F;figcaption&gt;
	

&lt;&#x2F;figure&gt;

	&lt;small&gt;&lt;span class=&quot;codeblock-name&quot;&gt;&lt;a href = &quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;competitive-programming&#x2F;dsa-explanations&#x2F;basic-segment-tree&#x2F;code&#x2F;segtree-two-power&#x2F;src&#x2F;max_segtree.rs&quot;&gt;code&amp;#x2F;segtree-two-power&amp;#x2F;src&amp;#x2F;max_segtree.rs&lt;&#x2F;a&gt;&lt;&#x2F;span&gt;&lt;&#x2F;small&gt;
&lt;pre data-linenos data-lang=&quot;rust&quot; class=&quot;language-rust z-code&quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;46&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;    &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;pub&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-function z-rust&quot;&gt;fn&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function z-rust&quot;&gt;update&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-rust&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;mut&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;self&lt;&#x2F;span&gt;, &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;val&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;, &lt;span class=&quot;z-storage z-modifier z-rust&quot;&gt;mut&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-rust&quot;&gt;idx&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-storage z-type z-rust&quot;&gt;usize&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;47&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        idx &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;+=&lt;&#x2F;span&gt; N &lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;-&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;48&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;idx&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; val&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;49&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        idx &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;&#x2F;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;50&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;51&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;span class=&quot;z-keyword z-control z-rust&quot;&gt;while&lt;&#x2F;span&gt; idx &lt;span class=&quot;z-keyword z-operator z-comparison z-rust&quot;&gt;!=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;0&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-begin z-rust&quot;&gt;{&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;52&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            &lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;idx&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-generic z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-begin z-rust&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-rust&quot;&gt;u32&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-generic z-end z-rust&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-path z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-rust&quot;&gt;::&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;max&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;*&lt;&#x2F;span&gt;idx&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-rust&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-language z-rust&quot;&gt;self&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-rust&quot;&gt;.&lt;&#x2F;span&gt;buf&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-rust&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;*&lt;&#x2F;span&gt;idx &lt;span class=&quot;z-keyword z-operator z-arithmetic z-rust&quot;&gt;+&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-group z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-rust&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;53&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;            idx &lt;span class=&quot;z-keyword z-operator z-assignment z-rust&quot;&gt;&#x2F;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-rust&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-terminator z-rust&quot;&gt;;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;54&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;        &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;55&lt;&#x2F;td&gt;&lt;td&gt;&lt;span class=&quot;z-source z-rust&quot;&gt;&lt;span class=&quot;z-meta z-function z-rust&quot;&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;    &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-block z-rust&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-end z-rust&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;!--
## Segment Tree with a general amount of elements

The ideas above can also be applied to a Segment Tree with a general amount of elements: we can halve _ranges_. We know that all ranges can be constructed halved ranges (as they include $[i, i]$ - in the worst case we can simply use that).

We break $[l, r]$ into $\left[{1, \left\lfloor\cfrac{l + r}{2}\right\rfloor}\right]$ and $\left[\left\lfloor\cfrac{l + r}{2}\right\rfloor + 1, N\right]$ while $l \ne r$. (It is apparent that the formula _always_ breaks consecutive ranges into two single-element ranges, which is where we stop splitting)
--&gt;
&lt;h1 id=&quot;segment-tree-with-a-general-amount-of-elements&quot;&gt;Segment Tree with a general amount of elements&lt;a class=&quot;zola-anchor&quot; href=&quot;#segment-tree-with-a-general-amount-of-elements&quot; aria-label=&quot;Anchor link for: segment-tree-with-a-general-amount-of-elements&quot;&gt;§&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;The ideas explored above can also be applied to arrays of any size with only slight changes. However, that is a topic for another day.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Hello World!</title>
        <published>2021-12-27T00:00:00+00:00</published>
        <updated>2021-12-27T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.vashishtha.in/hello-world/"/>
        <id>https://blog.vashishtha.in/hello-world/</id>
        
        <content type="html" xml:base="https://blog.vashishtha.in/hello-world/">&lt;p&gt;Hello World!&lt;&#x2F;p&gt;
&lt;p&gt;First off, this blog uses Zola, a static site generator written in Rust, and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;PabloMansanet&#x2F;zerm&quot;&gt;a modified version of this theme.&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As an icebreaker, here&#x27;s a nice picture of a tree I took a few a years ago:&lt;&#x2F;p&gt;
&lt;figure class=&quot;center&quot;&gt;&lt;img src=&quot;https:&#x2F;&#x2F;blog.vashishtha.in&#x2F;tree_picture.jpg&quot; alt=&quot;A picture of a lonely tree in front of a mountain range, with half of its leaves shedded and the other half still hanging on.&quot; &#x2F;&gt;
&lt;&#x2F;figure&gt;
&lt;p&gt;Though don&#x27;t worry; this isn&#x27;t a photography blog... yet.&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
