<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom">
  <title>Jiayi Zhuang’s Blog</title>
  <subtitle>Jiayi Zhuang’s personal blog and academic portfolio.</subtitle>
  <id>https://blog.wybxc.cc/</id>
  <link href="https://blog.wybxc.cc/"/>
  <link href="https://blog.wybxc.cc/atom.xml" rel="self" type="application/atom+xml"/>
  <updated>2026-08-22T00:00:00Z</updated>
  <author>
    <name>Jiayi Zhuang</name>
  </author>
  <entry>
    <title>A 2026 Survey of Rust GUI Libraries</title>
    <id>https://blog.wybxc.cc/blog/rust-gui-survey-2026/</id>
    <link href="https://blog.wybxc.cc/blog/rust-gui-survey-2026/"/>
    <published>2026-08-22T00:00:00Z</published>
    <updated>2026-08-22T00:00:00Z</updated>
    <content type="html" xml:base="https://blog.wybxc.cc/blog/rust-gui-survey-2026/">&lt;article&gt;&lt;aside class&gt;&lt;p&gt;Aug 22, 2026&lt;br&gt;48 mins read&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;&lt;nav role=&quot;doc-toc&quot;&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;div&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-1&quot;&gt;A 2026 Survey of Rust GUI Libraries&lt;/a&gt;&lt;/div&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-2&quot;&gt;Azul&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-3&quot;&gt;Blinc&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-4&quot;&gt;Cacao&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-5&quot;&gt;Core-Foundation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-6&quot;&gt;Crux&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-7&quot;&gt;Cushy&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-8&quot;&gt;CXX-Qt&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-9&quot;&gt;Dioxus&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-10&quot;&gt;Dominator&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-11&quot;&gt;Egui&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-12&quot;&gt;Floem&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-13&quot;&gt;FLTK&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-14&quot;&gt;Flutter Rust Bridge&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-15&quot;&gt;Freya&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-16&quot;&gt;Fui&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-17&quot;&gt;Gemgui&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-18&quot;&gt;GPUI&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-19&quot;&gt;GPUI Component&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-20&quot;&gt;GTK 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-21&quot;&gt;GTK 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-22&quot;&gt;Iced&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-23&quot;&gt;Imgui&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-24&quot;&gt;KAS&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-25&quot;&gt;Kittest&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-26&quot;&gt;Leptos&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-27&quot;&gt;Lvgl&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-28&quot;&gt;Makepad&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-29&quot;&gt;Masonry&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-30&quot;&gt;Maycoon&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-31&quot;&gt;Pane UI&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-32&quot;&gt;Pax&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-33&quot;&gt;Ply&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-34&quot;&gt;QMetaObject&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-35&quot;&gt;Relm&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-36&quot;&gt;Relm4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-37&quot;&gt;Ribir&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-38&quot;&gt;Rinf&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-39&quot;&gt;Rosin&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-40&quot;&gt;Rui&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-41&quot;&gt;SDL3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-42&quot;&gt;Slint&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-43&quot;&gt;Tauri&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-44&quot;&gt;Tessera&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-45&quot;&gt;Tinyfiledialogs&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-46&quot;&gt;Tk&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-47&quot;&gt;Undoredo&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-48&quot;&gt;Vizia&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-49&quot;&gt;WebRender&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-50&quot;&gt;Windows&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-51&quot;&gt;Windows Reactor&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-52&quot;&gt;WinSafe&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-53&quot;&gt;WxDragon&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-54&quot;&gt;Xilem&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-55&quot;&gt;Yew&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#the-table&quot;&gt;The Table&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/nav&gt;&lt;/aside&gt;&lt;h2 id=&quot;loc-1&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-1&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;A 2026 Survey of Rust GUI Libraries&lt;/h2&gt;&lt;p&gt;It has been more than one year since boringcactus’s &lt;a href=&quot;https://www.boringcactus.com/2025/04/13/2025-survey-of-rust-gui-libraries.html&quot;&gt;A 2025 Survey of Rust GUI Libraries&lt;/a&gt;. That was indeed a very interesting blog; so interesting that I wanted to try it myself. So I will be testing and reviewing each of the libraries listed on the &lt;a href=&quot;https://areweguiyet.com&quot;&gt;Are We GUI Yet?&lt;/a&gt; website.&lt;/p&gt;&lt;p&gt;The task I chose is a QR Code Generator. The interface has a text box; when text is entered, the Rust backend calculates the corresponding QR Code based on the text and displays it below the text box.&lt;/p&gt;&lt;div class=&quot;typst-center&quot;&gt;&lt;span class=&quot;typst-invert&quot;&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/500f12cdde9279ac.png&quot; width=&quot;848&quot; height=&quot;848&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;This task can cover many aspects that GUI frameworks need to consider. For example, the text box involves IME support, and displaying images from the backend tests the framework’s compatibility with the existing Rust ecosystem. In addition, this task is also a simplified version of a real example I encountered when I first used Rust to develop a GUI program this year.&lt;/p&gt;&lt;p&gt;Beyond basic feature completeness, I’ll also give a fairly subjective usability rating, covering state management, styling, the complexity of scaffolding an initial project, and the editor experience.&lt;/p&gt;&lt;p&gt;To get a realistic feel, I’ll try to hand-write each task as much as possible. Of course, in 2026, a major difference is the practical adoption of coding agents. If, during this survey, I come across a framework whose correct usage I can’t figure out myself, but a coding agent can write the correct code on my behalf, then I’ll still give that framework some credit for usability.&lt;/p&gt;&lt;p&gt;I’m on macOS, so the survey will be based on the macOS platform. For certain Windows-specific frameworks, I will also try running them in a Windows VM.&lt;/p&gt;&lt;p&gt;The &lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#conclusion&quot;&gt;conclusion&lt;/a&gt; and &lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#the-table&quot;&gt;the table&lt;/a&gt; are at the end of this article.&lt;/p&gt;&lt;h3 id=&quot;loc-2&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-2&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Azul&lt;/h3&gt;&lt;p&gt;When I opened Azul’s &lt;a href=&quot;https://azul.rs&quot;&gt;homepage&lt;/a&gt;, I was greeted by a rather ambitious page introducing Azlin Workspace, Azlin UI Toolkit, and Azlin OS. Although Azlin Workspace is basically a bunch of “Coming Soon” notices, and I’m not sure how Azlin relates to Azul, I still managed to get past the homepage and find the correct user documentation on GitHub.&lt;/p&gt;&lt;p&gt;It looks like Azul just released version 0.2.0, and according to the docs, I can simply install its runtime library via Homebrew. Then, since Azul isn’t published on crates.io, I had to clone its Git repo and run it to generate the Rust API bindings.&lt;/p&gt;&lt;p&gt;The first snag came right away: rust-analyzer didn’t recognize the Rust code that Azul generated. It compiled and ran fine, but all editor hints for the relevant types were gone.&lt;/p&gt;&lt;p&gt;Well, that’s not a huge deal; at least &lt;code&gt;cargo doc&lt;/code&gt; is available. It’s like going back to programming in the pre-LSP era.&lt;/p&gt;&lt;p&gt;After spending 10 minutes digging through the cargo docs and repeatedly invoking the compiler, I finally managed to stick a text box into its original example. But then, no matter what I did, I couldn’t get any text I typed into the box to actually show up. So I asked Codex to help me debug this issue, and it turned out that Azul apparently couldn’t read fonts installed on the system. That alone is almost enough to rule out using Azul for this purpose. Not wanting to waste any more of my time (and tokens), I decided to move on to the next framework.&lt;/p&gt;&lt;h3 id=&quot;loc-3&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-3&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Blinc&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://project-blinc.github.io/Blinc&quot;&gt;Blinc&lt;/a&gt; is a very new framework. It only released its first version in early 2026. Like many Rust GUI frameworks, Blinc uses wgpu as its rendering backend and adopts a reactive programming model. With rapid iteration, some examples in its official documentation are already outdated.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/27111a55f5df7776.png&quot; width=&quot;1024&quot; height=&quot;1088&quot; style=&quot;display: block; width: 30em&quot;&gt;&lt;p&gt;The &lt;code&gt;TextInput&lt;/code&gt; component feels unfinished: it doesn’t let you set a font, and its reactive behavior requires manually triggering in the &lt;code&gt;on_change&lt;/code&gt; event. Meanwhile, &lt;code&gt;TextArea&lt;/code&gt; allows you to specify a signal as the target to trigger when it updates. However, I don’t think either of these approaches really conforms to the reactive standard. True reactivity shouldn’t require you to manually handle events or signals; it should directly propagate changes in input controls to wherever the state is used.&lt;/p&gt;&lt;p&gt;&lt;code&gt;TextInput&lt;/code&gt;’s default font doesn’t support CJK character display. IME works fine, but the composer position doesn’t align with the text box position.&lt;/p&gt;&lt;p&gt;macOS’s accessibility features don’t work either; screen readers can’t read out the content in the window.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Engine&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;blinc_app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;blinc_app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;windowed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowedApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowedContext&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tracing_subscriber&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_max_level&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tracing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Level&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;INFO&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;config&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowConfig&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QRCode Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;resizable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowedApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;build_ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build_ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ctx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowedContext&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ElementBuilder&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ctx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;use_state_keyed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_input_state_with_placeholder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;https://example.com&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ctx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ctx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;10.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;flex_col&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bg_surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;24.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_center&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_change&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;stateful&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NoState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;deps&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;signal_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;lock&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_else&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b64&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;general_purpose&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;STANDARD&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;w_full&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;flex_grow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;flex_col&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;data:image/png;base64,{b64}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self_center&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-4&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-4&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Cacao&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/cacao/latest/cacao/&quot;&gt;Cacao&lt;/a&gt; is a Rust binding for macOS AppKit. Honestly, I’d never tried this crate before. I expected it to be full of unspeakable unsafe things interacting with low-level Objective-C code. But after actually using it, I found its API surprisingly clean.&lt;/p&gt;&lt;p&gt;Cacao’s recommended programming model is event-driven. Components in the inner layers can send events to the top level, where an event dispatcher modifies the state based on the information carried by the events. This is somewhat similar to the Elm architecture, but not as purely functional.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/8987375023d539a1.png&quot; width=&quot;1024&quot; height=&quot;1024&quot; style=&quot;display: block; width: 30em&quot;&gt;&lt;p&gt;Since it uses native macOS text input boxes, IME support is excellent.&lt;s&gt;What surprised me, though, is that the screen reader didn’t work properly. It seems some setting might need to be enabled, but I don’t want to spend more effort digging through the docs to find it.&lt;/s&gt; Screen reader also works properly.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Mutex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cacao&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;appkit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowConfig&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowDelegate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cacao&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;appkit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppDelegate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cacao&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageView&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cacao&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextField&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextFieldDelegate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cacao&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LayoutConstraint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cacao&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;notification_center&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Dispatcher&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cacao&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cacao&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;View&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowConfig&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppDelegate&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;did_finish_launching&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;activate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_minimum_content_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;400.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;400.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;should_terminate_after_last_window_closed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;bool&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Dispatcher&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Message&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_ui_message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_else&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;delegate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;lock&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_view&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;lock&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextField&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageView&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Mutex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;View&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextField&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageView&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Mutex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;View&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowDelegate&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;NAME&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;WindowDelegate&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;did_load&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_minimum_content_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;300.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;300.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add_subview&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add_subview&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add_subview&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_content_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LayoutConstraint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;activate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;center_x&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;center_x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;top&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;safe_layout_guide&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to_constant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;280.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to_constant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;30.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;center_x&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;safe_layout_guide&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;center_x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;top&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;safe_layout_guide&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;30.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to_constant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;280.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_view&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;center_x&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;center_x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_view&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;top&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;safe_layout_guide&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;50.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to_constant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;constraint_equal_to_constant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextFieldDelegate&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyInput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;NAME&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;MyInput&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_did_change&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dispatch_main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;com.hello.world&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-5&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-5&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Core-Foundation&lt;/h3&gt;&lt;p&gt;Strictly speaking, &lt;a href=&quot;https://docs.rs/core-foundation/latest/core_foundation/&quot;&gt;Core Foundation&lt;/a&gt; is not really a GUI library; it just provides some bindings to macOS system APIs. So I don’t think it’s reasonable for it to be listed on “Are We GUI Yet?”. In the same repository, there is a &lt;code&gt;cocoa&lt;/code&gt; crate that does provide bindings to the AppKit GUI library, but its underlying dependencies are outdated and it’s very unidiomatic Rust&lt;sup&gt;1&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;1.&lt;/span&gt;&lt;span&gt;which is what I meant by “unspeakable unsafe things interacting with low-level Objective-C code”&lt;/span&gt;&lt;/span&gt;, so I’ll skip it for now.&lt;/p&gt;&lt;h3 id=&quot;loc-6&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-6&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Crux&lt;/h3&gt;&lt;p&gt;Boringcactus gave &lt;a href=&quot;https://redbadger.github.io/crux/&quot;&gt;Crux&lt;/a&gt; a positive review in hir evaluation last year, but since ze said Crux only had mobile bindings and no desktop bindings, ze didn’t actually test its functionality. Today, while checking the documentation, I found that Crux now has macOS bindings, so I decided to actually pull it out and compare it here.&lt;/p&gt;&lt;p&gt;I followed Crux’s documentation to set up the project scaffold. Since Crux itself doesn’t provide a GUI but rather an interface from the Rust core to various GUI shells, setting up the scaffold is slightly more complex than the previous projects, but still within a reasonable level of complexity. Once the setup was complete, it was easy to change the functionality from the Counter example to this survey’s QR code generator.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/65fa278c6aadc4d2.png&quot; width=&quot;688&quot; height=&quot;896&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;On macOS, Crux uses SwiftUI for the interface. Since our evaluation criteria basically only look at the GUI side, it’s a bit unfair to compare SwiftUI with other Rust GUI frameworks. SwiftUI’s support for IME and screen readers is native and first-class.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;p&gt;Rust:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;crux_core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;bridge&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bridge&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EffectId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;crux_core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;macros&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;effect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;crux_core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RenderOperation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;crux_core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;facet&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Facet&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;serde&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Deserialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Serialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Counter&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Model&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ViewModel&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ViewModel&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Effect&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Effect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Effect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;match&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ViewModel&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ViewModel&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Facet&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Serialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Deserialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Debug&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;repr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;C&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;enum&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Model&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Facet&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Serialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Deserialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ViewModel&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;effect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;facet_typegen&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Debug&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;enum&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Effect&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RenderOperation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt; The main interface used by the shell
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CoreFfi&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bridge&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CoreFfi&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;boltffi&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CoreFfi&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;must_use&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bridge&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;must_use&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;effects&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;match&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;effects&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;effects&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;panic&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;{e}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;must_use&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;effects&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;match&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;EffectId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;effects&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;effects&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;panic&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;{e}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;must_use&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view_model&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;match&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view_model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view_model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;panic&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;{e}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Swift:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;swift&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;App&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;SwiftUI&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ImageIO&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ContentView&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;View&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ObservedObject&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;var&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Core&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;State&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;private&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;var&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;var&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;some&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;View&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;VStack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;spacing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;Enter text to generate QR code:&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;

            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;TextField&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;$text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;textFieldStyle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;roundedBorder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;maxWidth&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;newValue&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;in&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;newValue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qrImage&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qrImage&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;resizable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;interpolation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;scaledToFit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;Enter some text to generate a QR code&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;foregroundColor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;secondary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;maxWidth&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;infinity&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;maxHeight&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;infinity&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;private&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;var&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qrImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;guard&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
              &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;source&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;CGImageSourceCreateWithData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CFData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
              &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cgImage&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;CGImageSourceCreateImageAtIndex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;nil&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;decorative&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cgImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;scale&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Preview&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ContentView&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-7&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-7&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Cushy&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/cushy/latest/cushy/&quot;&gt;Cushy&lt;/a&gt; doesn’t seem to have changed much compared to a year ago. Even the comment in the README that doesn’t match the actual code hasn’t been fixed.&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s6&quot;&gt;// Create a dynamic usize.&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;count&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Dynamic&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0_isize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The last release is still from 2024, so I’m a bit skeptical about whether retesting Cushy has any value. Still, let’s give it a try; maybe things will be different on macOS compared to Windows.&lt;/p&gt;&lt;p&gt;Cushy’s code is surprisingly concise to write. Maybe I was just intimidated by the complexity of the previous frameworks, but being able to finish the main core logic of the project in just a dozen or so lines made for a very enjoyable development experience. Cushy’s API design is clean and intuitive, especially how a single &lt;code&gt;Dynamic&lt;/code&gt; type expresses almost all the reactive features and can easily be converted between data and components.&lt;/p&gt;&lt;p&gt;Even more noteworthy is that Cushy is the first framework in this survey that integrates with the existing Rust ecosystem. It supports directly converting a &lt;code&gt;DynamicImage&lt;/code&gt; from the &lt;code&gt;image&lt;/code&gt; crate into a &lt;code&gt;Texture&lt;/code&gt;, which saves a lot of intermediate conversion code.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/e446d021b4aff154.png&quot; width=&quot;670&quot; height=&quot;712&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;As for IME and screen reader support, the situation on macOS is similar to Windows. The intermediate results from the IME composer are not visible, but the final converter works fine&lt;sup&gt;2&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;2.&lt;/span&gt;&lt;span&gt;Check boringcactus’s &lt;a href=&quot;https://www.boringcactus.com/2025/04/13/2025-survey-of-rust-gui-libraries.html#egui&quot;&gt;2025 survey&lt;/a&gt; to learn what composer and converter in an IME are.&lt;/span&gt;&lt;/span&gt;, while the screen reader cannot recognize the content in the window.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cushy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;kludgine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LazyTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FilterMode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Dynamic&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Source&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MakeWidget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetInstance&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;widgets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputValue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cushy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Dynamic&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map_each&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;texture&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LazyTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FilterMode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Nearest&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetInstance&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;texture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;and&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;and&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_rows&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;titled&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-8&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-8&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;CXX-Qt&lt;/h3&gt;&lt;p&gt;Qt is indeed a framework that inspires both love and hate. On the one hand, Qt is almost inextricably tied to a language as intimidating as C++. But on the other hand, Qt’s cross-platform compatibility is quite good. I have more than once built personal macOS versions of open-source software written with Qt.&lt;/p&gt;&lt;p&gt;For myself, I probably wouldn’t choose to use Rust with Qt. But for the purpose of this survey, let’s take a look at this Rust binding for Qt.&lt;/p&gt;&lt;p&gt;When it comes to anything C++-related, environment setup is always the biggest headache. I didn’t want to spend time wrestling with Qt’s environment configuration, so I just installed Qt via Nix. Then I tried running the &lt;a href=&quot;https://kdab.github.io/cxx-qt/book/&quot;&gt;CXX-Qt&lt;/a&gt; example code – oh, compile errors.&lt;/p&gt;&lt;p&gt;Because the error report was a jumble of errors from Rust, C++, and various other places, I decided to stop thinking and hand the problem over to Codex.&lt;/p&gt;&lt;p&gt;What surprised me, though not at all unexpectedly, was that this compile error was a double problem. I won’t go into too much detail here; in short, the &lt;code&gt;qt-build-utils&lt;/code&gt; used by CXX-Qt doesn’t support the way Nix packages Qt, and cxx actually had a regression during a &lt;em&gt;patch&lt;/em&gt; version change (yet another SemVer joke). After an hour of discussion with the AI, I finally found a workaround to get it running. So let’s give it a try.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/43d873335d1dcec2.png&quot; width=&quot;778&quot; height=&quot;960&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;Images can only be passed between Rust and Qt via data URLs, which I’m not very fond of. IME and screen reader both work fine&lt;sup&gt;3&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;3.&lt;/span&gt;&lt;span&gt;On macOS, there are actually two screen reader implementations: the more comprehensive VoiceOver, and “Speak items under the pointer.” In CXX-Qt, only VoiceOver works properly; the second feature doesn’t read window content. From here on, “screen reader” refers to VoiceOver by default.&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;p&gt;Rust:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pin&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Engine&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cxx_qt_lib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QGuiApplication&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QQmlApplicationEngine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QUrl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QGuiApplication&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;engine&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QQmlApplicationEngine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QUrl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;qrc:/qt/qml/cc/wybxc/cxx_qt/demo/qml/main.qml&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode_data_url&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;min_dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b64&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;general_purpose&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;STANDARD&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;data:image/png;base64,{b64}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cxx_qt&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bridge&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mod&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qobject&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;unsafe&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;extern&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;C++&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;cxx-qt-lib/qstring.h&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cxx_qt_lib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;extern&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;RustQt&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qobject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qml_element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qproperty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qproperty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cxx_name&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;qrCode&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;namespace&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;my_object&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyObject&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyObjectRust&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qinvokable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cxx_name&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;generateQRCode&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;generate_qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pin&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyObjectRust&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cxx_qt_lib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cxx_qt_lib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qobject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyObject&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;generate_qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pin&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;url&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode_data_url&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cxx_qt_lib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;QML:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;qml&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QtQuick&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QtQuick&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Controls&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QtQuick&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wybxc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cxx_qt&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;demo&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ApplicationWindow&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;480&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qsTr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;640&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;palette&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;readonly&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;property&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyObject&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;myObject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyObject&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;onTextChanged&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;generateQRCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Column&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;anchors&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;parent&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;anchors&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;margins&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;10&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;spacing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;10&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qsTr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;palette&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextField&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;inputField&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;placeholderText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qsTr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;https://example.com&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;onTextChanged&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;myObject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qrCodeImage&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;fillMode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;PreserveAspectFit&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;myObject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qrCode&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;status&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;===&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Ready&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-9&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-9&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Dioxus&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/dioxus/latest/dioxus/&quot;&gt;Dioxus&lt;/a&gt; is basically React in Rust. According to their description, on desktop they use the Wry framework to run a WebView and display the UI inside it, which is essentially what Tauri does.&lt;/p&gt;&lt;p&gt;Recently, Dioxus’s development pace seems to have slowed down. There are reports that the team has shifted its focus to &lt;a href=&quot;https://github.com/DioxusLabs/blitz&quot;&gt;Blitz&lt;/a&gt;, a self-developed HTML/CSS rendering engine. The reason for this shift seems to be that AI agents nowadays need something that can render HTML more than they need a UI framework.&lt;/p&gt;&lt;p&gt;But regardless, this can be seen as a step for Dioxus to move away from WebView and toward a more native approach.&lt;/p&gt;&lt;p&gt;Incidentally, the niche of native rendering for Dioxus was originally occupied by Freya&lt;sup&gt;4&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;4.&lt;/span&gt;&lt;span&gt;We’ll see it later.&lt;/span&gt;&lt;/span&gt;. But now Freya has changed course, breaking away from Dioxus and adopting its own GUI model, so at the moment there isn’t really a native-rendering Dioxus anymore&lt;sup&gt;5&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;5.&lt;/span&gt;&lt;span&gt;As noted in Reddit comments, Dioxus already includes experimental native rendering support (powered by Blitz) in version 0.7, with further improvements expected in the upcoming 0.8 release.&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/7c9e57b5e5cf0892.png&quot; width=&quot;800&quot; height=&quot;996&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME and screen reader both work fine.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;dioxus&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;dioxus&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;launch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode_data_url&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b64&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;general_purpose&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;STANDARD&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;data:image/png;base64,{b64}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;component&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Element&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;use_signal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;use_memo&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode_data_url&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;rsx&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Title&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;main&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;display: flex; flex-direction: column&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;p&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;r#type&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text here&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;oninput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;evt&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;evt&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;{qr}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR code&quot;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-10&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-10&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Dominator&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/dominator/latest/dominator/&quot;&gt;Dominator&lt;/a&gt; is a web-oriented framework, and its situation hasn’t changed since 2025; it still doesn’t natively provide desktop support.&lt;/p&gt;&lt;h3 id=&quot;loc-11&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-11&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Egui&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/egui/latest/egui/&quot;&gt;Egui&lt;/a&gt; is a well-known immediate mode&lt;sup&gt;6&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;6.&lt;/span&gt;&lt;span&gt;If you’re curious about what immediate mode is, check out &lt;a href=&quot;https://www.boringcactus.com/2025/04/13/2025-survey-of-rust-gui-libraries.html#egui&quot;&gt;boringcactus’s 2025 survey&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt; GUI library in Rust. It supports multiple rendering backends, which allows it to be embedded in various game engines. Eframe is egui’s desktop integration. Last year, eframe still used glow as the default rendering backend. In version 0.34 released this year, Eframe’s default rendering backend has switched to egui-wgpu. It seems wgpu is becoming the de facto standard for Rust graphics rendering, and the ecosystem is unifying, which is great to see.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/ea05698b0637cf96.png&quot; width=&quot;818&quot; height=&quot;902&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;Egui’s default font doesn’t support CJK characters; you need to manually add a CJK-capable font before they can be displayed. IME and the screen reader both work properly. In last year’s article, Boringcactus mentioned that egui’s IME support had some issues, but in my tests everything worked fine. This could be due to platform differences between Windows and macOS, or it could be that egui has genuinely improved its IME support over the past year.&lt;/p&gt;&lt;p&gt;Among GUI frameworks that use wgpu for rendering, egui is the first to offer good accessibility support, which is great.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;eframe&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontDefinitions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontFamily&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;native_options&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;eframe&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NativeOptions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;eframe&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run_native&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;native_options&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyEguiApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyEguiApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureHandle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyEguiApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;eframe&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CreationContext&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;db&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fontdb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Database&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;load_system_fonts&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;db&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fontdb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Query&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;families&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fontdb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Family&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Hiragino Sans GB&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fontdb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Query&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;and_then&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_face_data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_owned&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;index&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;fonts&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontDefinitions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;fonts&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;font_data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;cjk&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;fonts&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;families&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontFamily&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Proportional&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;cjk&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;egui_ctx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_fonts&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;fonts&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;egui_ctx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;load_texture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;qr&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ColorImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_gray&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureOptions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;eframe&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyEguiApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;eframe&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CentralPanel&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;resp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextEdit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;singleline&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;resp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ColorImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_gray&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;egui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureOptions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size_vec2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-12&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-12&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Floem&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/floem/latest/floem/&quot;&gt;Floem&lt;/a&gt; is the UI framework used by Lapce, a code editor written in Rust. As a code editor with a similar positioning, Lapce seems to have stagnated in development compared to the thriving Zed. The last commit in its repository was 4 months ago, and its last release was 7 months ago. As for Floem, its UI framework, it hasn’t had a new release in nearly two years.&lt;/p&gt;&lt;p&gt;Floem’s code is also quite concise to write, reminding me of Cushy earlier. Here as well, a single &lt;code&gt;RwSignal&lt;/code&gt; type handles almost all reactive operations. In Floem, each component takes a closure that returns its display content. If you often deal with this kind of code in Rust, the moment you see a closure, you might feel a bit uneasy, because Rust’s ergonomics for capturing closures are still not great. Although there has been some discussion in the community, there doesn’t seem to be a stabilizable solution yet. But thank goodness, Floem’s &lt;code&gt;RwSignal&lt;/code&gt; type is actually &lt;code&gt;Copy&lt;/code&gt;, which means I don’t have to worry about how to copy it into each closure while writing code.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/a5f4b0b3aa1a9787.png&quot; width=&quot;710&quot; height=&quot;856&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;Unfortunately, IME doesn’t work properly – I can’t even switch input methods inside the text box, and the screen reader also can’t recognize the content in the window. Floem is regrettably poor in this regard. If the Lapce team has time to come back and take a look at their UI framework, maybe.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;floem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;reactive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SignalRead&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowConfig&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;IntoView&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RwSignal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;v_stack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;borrow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowConfig&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-13&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-13&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;FLTK&lt;/h3&gt;&lt;p&gt;“Rust bindings for the &lt;a href=&quot;https://docs.rs/fltk&quot;&gt;FLTK&lt;/a&gt; 1.4 Graphical User Interface library.”&lt;/p&gt;&lt;p&gt;The name FLTK sounds like something from the same era as Tcl, and you get the feeling that its widgets would be full of that last‑century style.&lt;/p&gt;&lt;p&gt;So I looked up the history of FLTK, and sure enough, it was born in 1998. However, after nearly 30 years of evolution, it is still being updated to this day. The latest version is FLTK 1.4.5.&lt;/p&gt;&lt;p&gt;The Rust bindings for FLTK bundle the upstream source code, so I don’t need to bother with environment setup.&lt;/p&gt;&lt;p&gt;Here I need to defend FLTK’s layout system. Boringcactus said that FLTK has no concept of a widget’s intrinsic size, but actually, as long as you place the widget inside a Flex layout, you can easily set its size; although it’s not something you’d immediately think of. I checked FLTK’s history, and at least by the time Boringcactus wrote that article, FLTK’s Flex was already available.&lt;/p&gt;&lt;p&gt;Like all GUI frameworks from 20 years ago&lt;sup&gt;7&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;7.&lt;/span&gt;&lt;span&gt;It reminds me of my elementary school days, programming with Visual Basic and Delphi on Windows XP.&lt;/span&gt;&lt;/span&gt;, FLTK uses a callback-based programming model; back then, the concept of reactive didn’t exist yet. One annoyance of using a callback-based model in Rust is the issue of component lifetimes. However, FLTK seems to handle this aspect quite well—at least for writing simple little programs like this, its approach to lifetimes is pretty intuitive.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/a7c3a18807d5d660.png&quot; width=&quot;824&quot; height=&quot;1008&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;FLTK offers several default themes, but no matter which one you choose, they all look like they’re straight out of 20 years ago. IME works fine in the text box, and after enabling &lt;code&gt;fltk_accesskit&lt;/code&gt;&lt;sup&gt;8&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;8.&lt;/span&gt;&lt;span&gt;Boringcactus once said integrating &lt;code&gt;fltk_accesskit&lt;/code&gt; was difficult, but now it only takes two lines of code. They improved this in the 0.2 version released in September 2025.&lt;/span&gt;&lt;/span&gt;, the screen reader can also recognize the content in the window.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fltk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fltk_accesskit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AccessibleApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PngImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PngImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;wind&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;360&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;col&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Flex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default_fill&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default_fill&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fixed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fixed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;wind&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_trigger&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;enums&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CallbackTrigger&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_callback&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_image_scaled&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;redraw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;wind&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ac&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;wind&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;attach&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run_with_accessibility&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ac&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-14&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-14&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Flutter Rust Bridge&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/flutter_rust_bridge/latest/flutter_rust_bridge/&quot;&gt;Flutter Rust Bridge&lt;/a&gt; is more of an FFI library between Rust and Flutter/Dart than a GUI library. From that perspective, it’s probably a bit more similar to Crux mentioned above.&lt;/p&gt;&lt;p&gt;I’ve tried some development with Flutter before, but perhaps my projects weren’t complex enough to need a Rust backend. I felt that keeping all the logic in Dart was actually sufficient. But since this library shows up on Are We GUI Yet?, let’s give it a try and see what the development experience is like when embedding Rust into Flutter.&lt;/p&gt;&lt;p&gt;Before I start, though, I hope I haven’t deleted the Flutter SDK from my computer. Setting it up from scratch every time is no easy task.&lt;/p&gt;&lt;p&gt;The Flutter Rust Bridge docs list over 6 ways to create a new project. Oh boy.&lt;/p&gt;&lt;p&gt;It seems Flutter now has a generic solution called “Native Assets” for integrating native backends, which, my intuition tells me, would save me the trouble of running code generators. Let’s make things a bit more challenging for ourselves and go with it.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/181c85667feb7d92.png&quot; width=&quot;918&quot; height=&quot;838&quot; style=&quot;display: block; width: 30em&quot;&gt;&lt;p&gt;Well, as it turns out, Native Assets didn’t save me from running code generators either. It seems like it just replaces the soon-to-be-deprecated cargokit. But Flutter developers are probably already used to running several code generators in watch mode in the background, so one more shouldn’t be a big deal.&lt;/p&gt;&lt;p&gt;In Flutter Rust Bridge, there are two modes of interaction between Rust and Flutter. The first is to treat Rust as a library of functions: you define functions in Rust, then call them from Flutter. State management is still handled by Flutter. This mode aligns with the general expectation for a native library, where you only offload performance-critical parts to the native library. However, there is another mode where you can define UI state in Rust and completely take over Flutter’s state management logic. In this case, Flutter is used purely as a DSL for defining GUI. That is to say, Flutter’s native state management mechanisms like controller/state become completely unusable; you have to feed all state back to Rust via callbacks, and then Rust handles it. The reason Boringcactus encountered IME issues in hir test was that ze tried to use Flutter’s controller in the second mode, which caused a new controller to be created on every render, leading to state conflicts. The code below shows the second mode.&lt;/p&gt;&lt;p&gt;Since the interface is Flutter, basic IME and screen reader functionality work fine. One interesting thing is that Flutter adds some extra navigation information to the screen reader, such as which keys you can press to move focus to a certain position.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;p&gt;Rust:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;flutter_rust_bridge&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;frb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui_state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RustState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RustState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;frb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;base_state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;frb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui_mutation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr_code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;frb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get_qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Flutter:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;dart&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&apos;package:flutter/material.dart&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&apos;package:hello_flutter_rust_bridge/src/rust/api/simple.dart&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&apos;package:hello_flutter_rust_bridge/src/rust/frb_generated.dart&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;runRustApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RustState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Widget&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RustState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;final&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qrCode&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;getQrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MaterialApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;home&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Scaffold&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
          &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
          &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextField&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;onChanged&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
          &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qrCode&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;memory&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-15&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-15&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Freya&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/freya/latest/freya/&quot;&gt;Freya&lt;/a&gt; was once a framework I had high expectations for. It had the ambitious goal of bringing Dioxus to native desktop rendering. But later, Freya felt that Dioxus was limiting its design, so it pivoted to developing its own GUI interface. Let’s try out the new Freya and see; hoping its developer interface is as easy to use as Dioxus.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/a11547c949fea217.png&quot; width=&quot;766&quot; height=&quot;950&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;Comparing the new Freya with the previous Dioxus example, it’s clear that Freya’s refactoring has simplified the code quite a bit. Dioxus’s model is faithful to the Web DOM, and replicating that model on desktop doesn’t actually bring any extra benefits.&lt;/p&gt;&lt;p&gt;Freya uses Skia as its rendering backend. In theory, I could create an image in Skia and hand it to Freya for rendering. But that’s too much hassle. Freya provides a way to create images directly from RGBA pixels, which is probably a bit better than using data URLs.&lt;/p&gt;&lt;p&gt;IME works properly in Freya, but the screen reader cannot recognize the content.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;freya&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageHandle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;launch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LaunchConfig&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowConfig&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageHandle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageHandle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AlphaType&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Premul&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;IntoElement&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;use_state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;use_memo&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Gaps&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new_all&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-16&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-16&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Fui&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/marek-g/rust-fui/blob/master/doc/SUMMARY.md&quot;&gt;Fui&lt;/a&gt; is an MVVM-style GUI framework. Its API design struck me as a bit novel because it actually requires using async to create windows and run the application.&lt;/p&gt;&lt;p&gt;Combining GUI with async/await is a fascinating idea. But so far, I haven’t seen any framework that really does this well.&lt;/p&gt;&lt;p&gt;Fui’s README doesn’t mention macOS support. I tried it and found that it indeed doesn’t. Alright, let’s move on to the next framework.&lt;/p&gt;&lt;h3 id=&quot;loc-17&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-17&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Gemgui&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/gemgui/latest/gemgui/&quot;&gt;Gemgui&lt;/a&gt; seems a bit mysterious. Its description is just one sentence: “Graphics User Interface library.”&lt;/p&gt;&lt;p&gt;After carefully reading the documentation, I found that gemgui is actually a framework written for Rust to integrate Web UIs. To make it seem comparable to other GUI frameworks, gemgui provides an option to run the Web UI using pywebview. This option requires you to download the pywebview library from PyPI. Using pywebview to pretend to be a native program is something I’ve done myself, but making a Rust program carry a Python runtime feels a bit top-heavy.&lt;/p&gt;&lt;p&gt;Although because it uses Web UI, its GUI score can’t really be compared with other libraries, I’m still curious about what the development experience is like. Would developing a Web UI application with such a library be better than using a general web server like axum or poem?&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/abcafc90f7a17349.png&quot; width=&quot;874&quot; height=&quot;1012&quot; style=&quot;display: block; width: 30em&quot;&gt;&lt;p&gt;The GUI development experience with gemgui is really intriguing: it almost brings a whole set of DOM operations into Rust. You can modify the DOM in Rust using equivalent operations, just as you would write DOM code in JS. For a project prototype, this is indeed a very convenient choice. If I can overlook the unexpectedly inefficient implementations in gemgui (such as the way it handles images), I’d say it’s a decent option for using WebUI in Rust.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;p&gt;Rust:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gemgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;graphics&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gemgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;graphics&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gemgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;graphics&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rgb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gemgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gemgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;GemGuiError&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;OUT_DIR&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;/generated.rs&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bitmap&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;iter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;rgb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;collect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;async&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;GemGuiError&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;fm&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gemgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;filemap_from&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;RESOURCES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;fm&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;hello.html&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gemgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;next_free_port&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;30000u16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// use python ui&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_python_gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;600&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_logging&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;textInput&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;subscribe_async&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;input&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;async&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ev&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ev&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;value&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;canvas&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;canvas&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;draw_bitmap_at&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;await&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;HTML:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;html&quot;&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;doctype html&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;html&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;meta&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;/&gt;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;meta&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;http-equiv&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Cache-Control&quot;&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;no-cache, no-store, must-revalidate&quot;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;/&gt;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;meta&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;http-equiv&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Pragma&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;no-cache&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;/&gt;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;meta&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;http-equiv&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;/&gt;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Hello&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;script&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;gemgui.js&quot;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;div&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt; flex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;flex-direction&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt; column&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;Enter text to generate QR code:&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;textInput&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text here&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;/&gt;&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;canvas&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;canvas&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;300&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;300&quot;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-18&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-18&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;GPUI&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://www.gpui.rs/&quot;&gt;GPUI&lt;/a&gt; is the UI framework that powers Zed. Lately, it feels like every so often I see someone on Reddit claiming they built some software’s UI with GPUI. As the name suggests, GPU rendering is its selling point. So what’s the user experience like as a UI framework? Let’s give it a try.&lt;/p&gt;&lt;p&gt;As of 2026, GPUI still doesn’t ship with a built-in text input component. I had to copy its 780-line text input example and build on top of it.&lt;/p&gt;&lt;p&gt;The first unfortunate thing was that the examples I copied from GitHub had clearly undergone API changes, so they wouldn’t compile when used with the version of GPUI from crates.io. Moreover, GPUI’s GitHub repository is located inside Zed’s subtree, and their tags are organized according to Zed’s version numbers, so I couldn’t even figure out which Git commit corresponded to the version they published on crates.io.&lt;/p&gt;&lt;p&gt;The second was that I stared at this 700-line example for quite a while without being able to tell what programming model GPUI actually uses. It seems its other examples only have a static &lt;code&gt;Render&lt;/code&gt;, so I couldn’t find any clue as to how they manage state. At this point, it has exceeded the patience limit of a programmer in 2026, so I decided to hand the remaining work over to AI.&lt;/p&gt;&lt;p&gt;While the AI was still hard at work, I casually browsed through GPUI’s examples to see what else was there. They actually have an example named &lt;code&gt;active_state_bug.rs&lt;/code&gt;, whose main content demonstrates one of their bugs: &lt;code&gt;.active()&lt;/code&gt; background gets stuck on every other click. Should I give them credit for their sense of humor?&lt;/p&gt;&lt;p&gt;Zed is an editor I really like, but it’s hard to imagine that the user experience of GPUI, which powers it, could be this bad. Look at Lapce and Floem over there; although Lapce isn’t as active as Zed nowadays, Floem as a UI framework is orders of magnitude better than GPUI.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/8ff846a331127b72.png&quot; width=&quot;726&quot; height=&quot;808&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME basically works, but the screen reader cannot access the content in the window. I say “basically” because while testing GPUI, I ran into an issue that none of the other UI frameworks had ever had: after typing a letter in the input method’s composer, deleting it, and then typing again, an out-of-bounds array access occurs and the program panics and exits. Could this be why GPUI hasn’t stabilized its text input as a built-in component because they themselves haven’t fully tested whether text input has bugs?&lt;/p&gt;&lt;p&gt;GPUI also has another example that integrates AccessKit. Perhaps following that example would make the screen reader work properly in GPUI, but I’ve run out of patience to keep dealing with it.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;div style=&quot;max-height: 30em; overflow: auto&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ClipboardItem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CursorStyle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ElementId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ElementInputHandler&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Entity&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EntityInputHandler&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FocusHandle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Focusable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;GlobalElementId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Keystroke&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LayoutId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseButton&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseDownEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseMoveEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseUpEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PaintQuad&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RenderImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ShapedLine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SharedString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextRun&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;UTF16Selection&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;UnderlineStyle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowBounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowOptions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;hsla&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rgb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;smallvec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SmallVec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;unicode_segmentation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;centered&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;300.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;300.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bind_keys&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;backspace&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Backspace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;delete&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Delete&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;left&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;right&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Right&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;shift-left&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SelectLeft&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;shift-right&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SelectRight&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;cmd-a&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SelectAll&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;cmd-v&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Paste&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;cmd-c&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Copy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;cmd-x&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;home&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;ctrl-cmd-space&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ShowCharacterPalette&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;open_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowOptions&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window_bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowBounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Windowed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Type here...&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection_reversed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;is_selecting&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;observe&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;detach&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputExample&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;recent_keystrokes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;vec&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;entity&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;observe_keystrokes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ev&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;recent_keystrokes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ev&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;keystroke&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;detach&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_keyboard_layout_change&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;detach&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;focus&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;activate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Quit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;quit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bind_keys&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;KeyBinding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;cmd-q&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Quit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Backspace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Delete&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Right&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SelectLeft&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SelectRight&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SelectAll&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ShowCharacterPalette&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Paste&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Copy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Quit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FocusHandle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SharedString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SharedString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection_reversed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ShapedLine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;is_selecting&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;move_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;previous_boundary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor_offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;move_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;right&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Right&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;move_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;next_boundary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;move_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SelectLeft&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;previous_boundary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor_offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_right&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SelectRight&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;next_boundary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor_offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_all&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SelectAll&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;move_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;home&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;move_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;move_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;backspace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Backspace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prev&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;previous_boundary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor_offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor_offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;==&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prev&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;replace_text_in_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Delete&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;next&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;next_boundary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor_offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor_offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;==&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;next&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;replace_text_in_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_mouse_down&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseDownEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;is_selecting&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;modifiers&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;shift&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;index_for_mouse_position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;move_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;index_for_mouse_position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_mouse_up&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseUpEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;is_selecting&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_mouse_move&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseMoveEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;is_selecting&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;index_for_mouse_position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;show_character_palette&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ShowCharacterPalette&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;show_character_palette&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;paste&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Paste&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;read_from_clipboard&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;and_then&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;replace_text_in_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Copy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to_clipboard&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ClipboardItem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to_clipboard&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ClipboardItem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;replace_text_in_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;move_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor_offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection_reversed&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;index_for_mouse_position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;y&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;y&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bottom&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;closest_index_for_x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;x&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;select_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection_reversed&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection_reversed&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection_reversed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;offset_from_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf8_offset&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf16_count&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ch&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;in&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;chars&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf16_count&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf16_count&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf8_offset&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len_utf8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf8_offset&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;offset_to_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf16_offset&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf8_count&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ch&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;in&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;chars&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf8_count&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf8_count&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len_utf8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf16_offset&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf16_offset&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_to_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;offset_to_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;offset_to_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_from_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;offset_from_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;offset_from_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;previous_boundary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;grapheme_indices&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;rev&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;find_map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;idx&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;then_some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;next_boundary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;grapheme_indices&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;find_map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;idx&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;then_some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EntityInputHandler&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_for_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;actual_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_from_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;actual_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_to_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;selected_text_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_ignore_disabled_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;UTF16Selection&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;UTF16Selection&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_to_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;reversed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection_reversed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;marked_text_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_to_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unmark_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;replace_text_in_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_from_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;or&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_owned&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;take&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;replace_and_mark_text_in_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_selected_range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_from_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;or&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_owned&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_selected_range_utf16&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_from_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_else&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bounds_for_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;last_layout&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;range_from_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_corners&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;last_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;x_for_index&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;last_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;x_for_index&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bottom&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;character_index_for_point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line_point&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_bounds&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;localize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;last_layout&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;assert_eq&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;last_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf8_index&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;last_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;index_for_x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;x&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line_point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;offset_to_utf16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;utf8_index&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextElement&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Entity&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PrepaintState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ShapedLine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PaintQuad&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PaintQuad&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;IntoElement&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextElement&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Element&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Element&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Element&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextElement&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RequestLayoutState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PrepaintState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PrepaintState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ElementId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;source_location&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;panic&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;request_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;GlobalElementId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_inspector_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InspectorElementId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LayoutId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;RequestLayoutState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;style&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;line_height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;request_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;prepaint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;GlobalElementId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_inspector_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InspectorElementId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_request_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;RequestLayoutState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;PrepaintState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;content&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;selected_range&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cursor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor_offset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;style&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;display_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;hsla&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;run&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextRun&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;display_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;background_color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;underline&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;strikethrough&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;runs&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;vec&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextRun&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextRun&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;underline&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;UnderlineStyle&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;thickness&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;wavy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextRun&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;display_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;marked_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;run&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_iter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;len&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;collect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;vec&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font_size&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;font_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;rem_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_system&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;shape_line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;display_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;runs&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cursor_pos&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;x_for_index&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cursor_pos&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bottom&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;blue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_corners&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;x_for_index&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;x_for_index&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;selected_range&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bottom&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0x3311ff30&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PrepaintState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;paint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;GlobalElementId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_inspector_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InspectorElementId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_request_layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;RequestLayoutState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prepaint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;PrepaintState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;focus_handle&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ElementInputHandler&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prepaint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;take&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;paint_quad&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prepaint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;take&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;paint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;line_height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_focused&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prepaint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;take&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;paint_quad&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_layout&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_bounds&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bounds&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Render&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;IntoElement&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;key_context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;TextInput&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;track_focus&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CursorStyle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IBeam&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;backspace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;right&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;select_left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;select_right&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;select_all&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;home&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;show_character_palette&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;paste&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_mouse_down&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseButton&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;on_mouse_down&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_mouse_up&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseButton&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;on_mouse_up&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_mouse_up_out&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseButton&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Left&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;on_mouse_up&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_mouse_move&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listener&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;on_mouse_move&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;rgb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0xeeeeee&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;line_height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;30.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;24.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;30.&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;4.&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;w_full&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;4.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextElement&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;entity&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Focusable&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FocusHandle&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputExample&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Entity&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;recent_keystrokes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Keystroke&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FocusHandle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Focusable&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputExample&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FocusHandle&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Render&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputExample&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;IntoElement&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;track_focus&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;focus_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;flex_col&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size_full&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rgba&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;quiet_zone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;min_dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// to BGRA&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;pixel&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;in&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;pixels_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;pixel&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RenderImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SmallVec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_elem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;100.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-19&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-19&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;GPUI Component&lt;/h3&gt;&lt;p&gt;&lt;em&gt;Edit on 2026-08-23:&lt;/em&gt;&lt;/p&gt;&lt;p&gt;After this blog post was published, there was considerable discussion in the community about &lt;a href=&quot;https://longbridge.github.io/gpui-component/&quot;&gt;GPUI Component&lt;/a&gt;. Many said it could completely transform the GPUI development experience, and is the only proper way to use GPUI for non-Zed developers. I therefore decided to add a section here to explore what using GPUI Component feels like.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/d4b83d9f15be55cc.png&quot; width=&quot;720&quot; height=&quot;860&quot; style=&quot;display: block&quot;&gt;&lt;p&gt;IME input works correctly, and screen readers are functional as well. However, to make text in the UI accessible to screen readers, I need to use GPUI’s &lt;code&gt;text!&lt;/code&gt; macro. If text is placed directly in the interface, or via the &lt;code&gt;Label&lt;/code&gt; component from GPUI Component, that text will not be recognized by screen readers.&lt;/p&gt;&lt;p&gt;With the code simplifications enabled by GPUI Component, I can finally get a clear picture of how GPUI manages state. GPUI organizes the UI into a component tree and a render tree. The component tree is responsible for managing state and event subscriptions. Each time the view is redrawn, the component tree derives a render tree. This is somewhat reminiscent of React before functional components were introduced, but by leveraging Rust’s RAII mechanism, GPUI can manage the lifecycle of the component tree more naturally.&lt;/p&gt;&lt;p&gt;I briefly looked through the GPUI Component codebase, and its repository size seems comparable to that of GPUI itself. Many thanks to the GPUI Component developers.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;gpui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui_component&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;StyledExt&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;HelloWorld&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Entity&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;_subscription&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Subscription&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;HelloWorld&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;subscription&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;subscribe_in&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Change&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;_subscription&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;subscription&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Render&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;HelloWorld&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;IntoElement&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;v_flex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;gap_2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size_48&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_any_element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size_48&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_any_element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui_platform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_assets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui_component_assets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Assets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gpui_component&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;spawn&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;async&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;open_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowOptions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_window_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;HelloWorld&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Failed to open window&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;detach&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-20&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-20&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;GTK 3&lt;/h3&gt;&lt;p&gt;“UNMAINTAINED Rust bindings for the &lt;a href=&quot;https://gtk-rs.org/gtk3-rs/stable/latest/docs/gtk/&quot;&gt;GTK+ 3&lt;/a&gt; library (use gtk4 instead).”&lt;/p&gt;&lt;p&gt;That’s what Are We GUI Yet? and crates.io say. But when I went and checked their GitHub repository, it had actually been updated as recently as yesterday (2026-08-18), and quite frequently at that. However, they indeed haven’t released a new version in nearly three years or more. I’m a bit curious what’s going on here, so why not give their GitHub version a try?&lt;/p&gt;&lt;p&gt;First off, there’s a Rust version issue. The library was updated to the Rust 2024 edition in a commit from a few days ago, but a piece of code gated by &lt;code&gt;#[cfg(macos)]&lt;/code&gt; still uses the old syntax, so it won’t compile on the newer Rust compiler, while older compilers will reject it because the rest of the code has already been upgraded to the 2024 edition. Fortunately, pinning the version to a slightly earlier commit solves the problem.&lt;/p&gt;&lt;p&gt;I thought I would need to use Nix again to solve the native library dependencies. But then I found I had installed GTK via Homebrew at some point. Well, at least that saves me from having to fiddle with the environment any further.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/656db3ab32a0dc87.png&quot; width=&quot;688&quot; height=&quot;874&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME doesn’t work properly, and the screen reader can’t recognize the window’s content either. I noticed that the GTK 3 repository has bindings for ATK (Accessibility Toolkit), but I couldn’t find documentation on how to integrate ATK into GTK.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gdk_pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Colorspace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;glib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ApplicationWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;application_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;org.example.HelloWorld&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;connect_activate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;win&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ApplicationWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;orientation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Orientation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vertical&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;spacing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;win&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Entry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;connect_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_from_pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;win&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;show_all&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ImageLuma8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_rgb8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_owned&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Colorspace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Rgb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-21&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-21&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;GTK 4&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4&quot;&gt;GTK 4&lt;/a&gt; overall feels quite similar to GTK 3. I was able to take the code I had in GTK 3, make a few small changes, and run it on GTK 4.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/0dd77f9f7d54f5cd.png&quot; width=&quot;624&quot; height=&quot;810&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME now works properly, which is an improvement over GTK 3. However, the screen reader still can’t recognize the content in the window. The GTK documentation has plenty about accessibility, so why doesn’t it actually work in practice?&lt;/p&gt;&lt;p&gt;Unlike on Windows, GTK on macOS doesn’t use its client-side window decorations; instead, it opts for server-side decorations like other applications. At least that way it doesn’t look so out of place.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;gtk4&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;glib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ApplicationWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gdk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;application_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;org.example.HelloWorld&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;connect_activate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;win&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ApplicationWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;orientation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Orientation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vertical&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;spacing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;win&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Entry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Picture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width_request&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height_request&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;connect_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_paintable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;win&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;present&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ImageLuma8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_rgb8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;R8g8b8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-22&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-22&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Iced&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/iced/latest/iced/&quot;&gt;Iced&lt;/a&gt; is a GUI framework that uses the Elm Architecture as its model. The so-called Elm Architecture originates from the frontend framework Elm and is a way of writing GUIs using functional programming. It requires centralizing all program state in one place and treating it as the single source of truth. The program’s interface can be determined by computing from the state, and GUI inputs are represented as transitions from the current state to a new state. &lt;sup&gt;9&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;9.&lt;/span&gt;&lt;span&gt;If you want a more functional programming-style explanation, the Elm Architecture decomposes a GUI program into a reader monad and a state monad. Although this perspective does no help with writing programs.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;In my personal experience, the Elm Architecture is beautiful in theory, but in practice it comes with many subtle points of friction. For example, in a sufficiently large GUI program, it’s true that most state is meant to be globally available, and lifting it into a common model makes sense. But there is also plenty of state that is meant as internal detail, only used by a specific component. If you have to put all that state into the global state as well, the abstraction leak problem becomes quite severe.&lt;/p&gt;&lt;p&gt;I’ve rambled on enough. I haven’t actually used iced before, so let’s see how it works in practice.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/7f2dd3023c67377a.png&quot; width=&quot;710&quot; height=&quot;862&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME works fine, but the screen reader cannot recognize the content in the window.&lt;/p&gt;&lt;p&gt;For a simple example like this, the Elm Architecture is still quite comfortable to use.&lt;/p&gt;&lt;p&gt;However, there’s one small thing to nitpick about iced’s widget DSL. Since they already use macros like &lt;code&gt;column!&lt;/code&gt; when creating widget lists, they could go further and customize the syntax. For example, for dynamic widget creation scenarios, they could support Flutter-style insertion of &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;for&lt;/code&gt; expressions directly in the list, like this:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s4&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;https://example.com&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;SetText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote&gt;&lt;p&gt;&lt;em&gt;Edit 2026-08-23:&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Reddit user throwing_in_silence pointed out that an &lt;code&gt;Option&amp;lt;impl Into&amp;lt;Element&gt;&gt;&lt;/code&gt; can be used directly in a widget list, so the above code can be changed to the following realistic version:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s4&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;https://example.com&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;SetText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This simplifies the code, but how would a user know? They’d have to notice in the &lt;code&gt;Element&lt;/code&gt; docs that &lt;code&gt;Element&lt;/code&gt; implements &lt;code&gt;From&amp;lt;Option&amp;lt;T&gt;&gt;&lt;/code&gt;, but someone writing an optional component is unlikely to look there. Even knowing the answer, I first checked &lt;code&gt;Widget&lt;/code&gt; trait and found nothing, then the &lt;code&gt;column!&lt;/code&gt; macro revealed it accepts &lt;code&gt;Into&amp;lt;Element&gt;&lt;/code&gt;, which led me to &lt;code&gt;Element&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;This reminds me of something interesting I encountered later while exploring Xilem. Similarly in Xilem, I didn’t realize &lt;code&gt;Option&amp;lt;T&gt;&lt;/code&gt; could go directly in the component list. My first attempt used a branch of two- and three-element versions, requiring type erasure to &lt;code&gt;AnyWidgetView&lt;/code&gt; (&lt;code&gt;dyn AnyView&lt;/code&gt;). The &lt;code&gt;AnyWidgetView&lt;/code&gt; docs then noted that I can insert an &lt;code&gt;Option&lt;/code&gt; into a &lt;code&gt;ViewSequence&lt;/code&gt;. This is surprising since there is no obvious connection between &lt;code&gt;AnyWidgetView&lt;/code&gt; and &lt;code&gt;ViewSequence&lt;/code&gt;. It’s likely that someone hit this, discovered &lt;code&gt;Option&lt;/code&gt;, and asked the author to add that note.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Another point is that iced’s documentation discoverability is not great. Because many of its widgets (like &lt;code&gt;image&lt;/code&gt;) are generic, and when creating them you need to pass a generic type parameter. You have to dig into the docs to find the default implementation of that generic to know how to construct that parameter.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;iced&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;iced&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;iced&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;iced&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Debug&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Debug&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;enum&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Message&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;SetText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;match&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;message&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;SetText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;children&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;https://example.com&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;SetText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;spacing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;children&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;pixels&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ImageLuma8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-23&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-23&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Imgui&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/imgui&quot;&gt;Imgui&lt;/a&gt; is a Rust binding for Dear ImGui, a C++ immediate-mode GUI library. My main impression of Dear ImGui is its distinctive style: it always renders at a low resolution no matter what screen it’s on.&lt;/p&gt;&lt;p&gt;Imgui doesn’t seem very active. Its last release was two years ago, though the GitHub repo still sees occasional updates every month or two.&lt;/p&gt;&lt;p&gt;The main imgui repo doesn’t have any complete examples; just a code snippet in the README. The README links to an imgui-examples repo that hasn’t been updated in two years. I looked for the simplest example there, but all of them rely on a 100+ line shared file for window setup, and that file uses the glium backend, which is already marked deprecated in the main repo’s README.&lt;/p&gt;&lt;p&gt;There’s a newer &lt;code&gt;imgui-wgpu&lt;/code&gt; backend available, but after digging through the repo and docs, it looks like I’d have to set up a wgpu context by hand. Ugh, modern graphics. My head already hurts.&lt;/p&gt;&lt;p&gt;Fortunately, I could build on the &lt;code&gt;imgui-wgpu&lt;/code&gt; example. Although the example is full of boilerplate code for creating windows and managing the wgpu context, it was still fairly easy to modify.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/60dea9d151e7818b.png&quot; width=&quot;828&quot; height=&quot;920&quot; style=&quot;display: block; width: 30em&quot;&gt;&lt;p&gt;IME is not supported, and neither is the screen reader.&lt;/p&gt;&lt;p&gt;For comparison, I feel that imgui’s API design is a bit cleaner than egui’s. But at the same time, because imgui exposes a lot of details about the underlying renderer, it’s not actually that clean in practice. Also, since imgui is a binding for a C++ library, in some places it has to follow conventions from the C++ ecosystem. For example, a text input can’t accept a string containing &lt;code&gt;&apos;\0&apos;&lt;/code&gt; (although I have no idea what keyboard could even produce such a string).&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;div style=&quot;max-height: 30em; overflow: auto&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;imgui_wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RendererConfig&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Texture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureConfig&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;imgui_winit_support&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WinitPlatform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pollster&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;block_on&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Extent3d&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;winit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ApplicationHandler&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;dpi&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LogicalSize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ActiveEventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ControlFlow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;keyboard&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NamedKey&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImguiState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WinitPlatform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;clear_color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MouseCursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface_desc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SurfaceConfiguration&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;hidpi_factor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImguiState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;setup_gpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ActiveEventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;instance&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Instance&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InstanceDescriptor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;backends&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Backends&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;PRIMARY&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InstanceDescriptor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new_with_display_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;owned_display_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LogicalSize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1280.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;720.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;attributes&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default_attributes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_inner_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;attributes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;inner_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;hidpi_factor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;scale_factor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;surface&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;instance&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create_surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;adapter&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;block_on&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;instance&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;request_adapter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RequestAdapterOptions&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;power_preference&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PowerPreference&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;HighPerformance&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;compatible_surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;force_fallback_adapter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;block_on&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;adapter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;request_device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DeviceDescriptor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// Set up swap chain&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;surface_desc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SurfaceConfiguration&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureUsages&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;RENDER_ATTACHMENT&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bgra8UnormSrgb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;present_mode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PresentMode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Fifo&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;desired_maximum_frame_latency&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;alpha_mode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CompositeAlphaMode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Auto&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;view_formats&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;vec&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bgra8Unorm&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;configure&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;surface_desc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface_desc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;hidpi_factor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;setup_imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;context&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;platform&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;imgui_winit_support&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WinitPlatform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;attach_window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;io_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;imgui_winit_support&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;HiDpiMode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_ini_filename&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font_size&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;13.0&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;hidpi_factor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;io_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;font_global_scale&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1.0&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;/&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;hidpi_factor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fonts&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add_font&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontSource&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;DefaultFontData&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontConfig&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;size_pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;clear_color&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Color&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;renderer_config&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RendererConfig&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;texture_format&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface_desc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;renderer&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;renderer_config&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;last_frame&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;last_cursor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;imgui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImguiState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;clear_color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ActiveEventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;setup_gpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;setup_imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ApplicationHandler&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;resumed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ActiveEventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;window_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ActiveEventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;winit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;match&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Resized&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface_desc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface_desc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;configure&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface_desc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ScaleFactorChanged&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;scale_factor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;..&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;hidpi_factor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;scale_factor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font_size&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;13.0&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;hidpi_factor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fonts&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clear&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fonts&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add_font&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontSource&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;DefaultFontData&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontConfig&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;oversample_h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;pixel_snap_h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;size_pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;font_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;reload_font_texture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;CloseRequested&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;KeyboardInput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;..&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Key&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Named&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NamedKey&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Escape&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;logical_key&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_pressed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;RedrawRequested&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;now&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;io_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update_delta_time&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;now&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_frame&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;match&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get_current_texture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CurrentSurfaceTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Success&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CurrentSurfaceTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Suboptimal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CurrentSurfaceTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Timeout&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CurrentSurfaceTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Occluded&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CurrentSurfaceTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Outdated&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CurrentSurfaceTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Lost&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;configure&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;surface_desc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;other&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;eprintln&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;get_current_texture error: {other:?}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;platform&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;prepare_frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;io_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Failed to prepare frame&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// Clone before the closure: `window` is already mutably&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// borrowed via `imgui`, and Device/Queue are cheap Arc clones.&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;device&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;queue&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;300.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;100.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Condition&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;FirstUseEver&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;input_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;raw_data&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;texture_config&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureConfig&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Extent3d&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;qrcode&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgba8Unorm&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;texture&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Texture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;texture_config&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;texture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;raw_data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;textures&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;texture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CommandEncoder&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create_command_encoder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CommandEncoderDescriptor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_cursor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mouse_cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;last_cursor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mouse_cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;prepare_render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;texture&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextureViewDescriptor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rpass&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;begin_render_pass&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RenderPassDescriptor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;color_attachments&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RenderPassColorAttachment&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;resolve_target&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Operations&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LoadOp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Clear&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;clear_color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wgpu&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;StoreOp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Store&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;depth_slice&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;depth_stencil_attachment&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;timestamp_writes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;occlusion_query_set&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;multiview_mask&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;renderer&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rpass&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Rendering failed&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rpass&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;submit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;encoder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;finish&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;present&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;io_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;WindowEvent&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;user_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ActiveEventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;io_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;UserEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;device_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ActiveEventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;device_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;winit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DeviceId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;winit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DeviceEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;io_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;DeviceEvent&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;device_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;about_to_wait&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ActiveEventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;request_redraw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;imgui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;io_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;AboutToWait&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;env_logger&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_control_flow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ControlFlow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run_app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-24&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-24&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;KAS&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/kas/&quot;&gt;KAS&lt;/a&gt; is a Rust GUI framework that pursues simplicity.&lt;/p&gt;&lt;p&gt;KAS’s repository links to their tutorial and their blog. I really like open-source projects that maintain a blog, because the thought processes and the principles and rationale behind the project design recorded by the developers are often worth learning from, even for people who don’t use the project. In KAS’s blog, there is also a &lt;a href=&quot;https://kas-gui.github.io/blog/state-of-GUI-2022.html&quot;&gt;State of GUI 2022&lt;/a&gt; that can be compared with the current state of things.&lt;/p&gt;&lt;p&gt;KAS’s programming model falls somewhere between React’s reactive model and the Elm Architecture. It allows attaching state to intermediate nodes in the component tree, where those nodes handle events and state updates from child components separately. Intuitively, this approach seems like it could solve the abstraction leak problem in the Elm Architecture. However, I can’t say for sure how composable it actually is. Because it looks like they ran into some trouble composing stateful widgets, so they specifically designed a macro-based syntax for widget composing. Incidentally, this architecture design reminds me of Blinc’s stateful components mentioned earlier, although I get the feeling the Blinc also hasn’t fully figured out how to manage state in their programs.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/10b311cf5f44e3ca.png&quot; width=&quot;790&quot; height=&quot;938&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME and the screen reader both don’t work properly. However, interestingly, in KAS’s repository, I also saw tracking issues regarding IME and screen reader support. They both started in June 2025. Judging from the timing, it’s quite likely they were influenced by the 2025 survey. Hopefully they’ll keep up the momentum this year.&lt;/p&gt;&lt;p&gt;As expected, when trying to compose components with different states, KAS’s API has a lot of friction. It reminds me of the days of playing with parser combinators. However, parser combinators generally provide a way to degrade types to &lt;code&gt;dyn Trait&lt;/code&gt; to reduce type-system complexity. But for some reason, in KAS, they didn’t choose to do this for widget types. This means when you want to create a series of widgets side by side, you have only two options: either use macros like &lt;code&gt;column!&lt;/code&gt;, or hand-write a type to combine these components. The former is almost unusable for cross-component communication, because the local types generated by macros are completely opaque, making it impossible to get references to child components. The API for custom components also seems rough. For example, while writing this example, habits from other frameworks told me that I should feed the &lt;code&gt;TextEdited&lt;/code&gt; event information back into the state, i.e., the controlled component mechanism from React. But it actually works without doing that. I don’t quite understand why, but it runs, so let’s just leave it at that.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;kas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;draw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Sprite&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;widgets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Debug&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextEdited&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ImageLuma8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;splat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;cast&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;impl_self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mod&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;QrApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sprite&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;widget_core&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;adapt&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EditBox&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;edit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InstantParseGuard&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;sprite&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;adapt&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Sprite&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate a QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;sprite&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Sprite&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_logical_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EditBox&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;instant_parser&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextEdited&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Events&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Data&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_messages&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EventCx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextEdited&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;try_pop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;draw&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;draw_shared&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;draw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image_alloc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;draw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image_upload&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;sprite&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;kas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;runner&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;env_logger&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;https://example.com/&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;kas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;runner&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Runner&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-25&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-25&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Kittest&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/kittest/latest/kittest/&quot;&gt;Kittest&lt;/a&gt; is a UI automation testing framework based on AccessKit, and it currently provides egui integration. Clearly, it’s not a framework for building GUIs, so let’s move on to the next one.&lt;/p&gt;&lt;h3 id=&quot;loc-26&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-26&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Leptos&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/leptos/latest/leptos/&quot;&gt;Leptos&lt;/a&gt; is a Rust framework for building full-stack web apps. On the UI side, it adopts a fine-grained reactive model. Leptos doesn’t provide a mode for packaging applications as desktop apps like Dioxus does; their focus is clearly more on the web domain.&lt;/p&gt;&lt;h3 id=&quot;loc-27&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-27&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Lvgl&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/lvgl/latest/lvgl/&quot;&gt;Lvgl&lt;/a&gt; is a Rust binding for a GUI library developed for embedded devices. That’s certainly a distinctive niche, and perhaps that alone is enough to make it stand out on Are We GUI Yet?. As far as I know, another GUI framework that can run in embedded environments is Slint. However, I don’t have a usable embedded development board on hand, and this survey’s scope is basically limited to desktop environments, so I can’t pit them against each other in an embedded setting.&lt;/p&gt;&lt;p&gt;Lvgl can also run in desktop mode, simulating the peripherals of an embedded device. In that case, it uses SDL as the rendering backend. This mode sounds like it’s mainly meant for developers to debug their programs before flashing them onto a board, so I find it hard to have high expectations for its performance as a desktop GUI.&lt;/p&gt;&lt;p&gt;The last release was three years ago. When I tried running the version on crates.io, it hit a segmentation fault. So I switched to the latest version on the main branch on GitHub, and after some painful environment setup, I finally got it running.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/b87b178de2b09950.png&quot; width=&quot;1184&quot; height=&quot;1728&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;Given that embedded devices don’t always have a keyboard, lvgl doesn’t respond to keyboard events. You need to add a Keyboard widget and click on it to enter text. Well, that’s certainly a refreshing experience. Of course, in this case there’s no way to talk about IME support or accessibility.&lt;/p&gt;&lt;p&gt;Despite all this time, lvgl’s Rust bindings still seem to be in an unfinished state. Many operations require getting raw pointers to widgets and going through the low-level lvgl-sys. For example, getting the text from a text box and setting the content of an image widget. Yes, that’s the only way to make the image widget usable.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cstr_core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CStr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cstr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;embedded_graphics&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pixelcolor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgb565&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;embedded_graphics&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;embedded_graphics_simulator&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;OutputSettingsBuilder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SimulatorDisplay&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SimulatorEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;input_device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;InputDriver&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;input_device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pointer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pointer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PointerInputData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;widgets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Keyboard&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Textarea&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Align&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Display&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DrawBuffer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LvError&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NativeObject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;HOR_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u32&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;240&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;VER_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u32&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;360&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u32&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;GrayImage&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;max_dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;quiet_zone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;pixel&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;in&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;enumerate_pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u16&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;pixel&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;128&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0x0000&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0xFFFF&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// RGB565 black/white&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;i&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;y&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;c&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0xFF&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;i&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;c&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LvError&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sim_display&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SimulatorDisplay&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgb565&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SimulatorDisplay&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;HOR_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;VER_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;output_settings&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;OutputSettingsBuilder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;scale&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;output_settings&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buffer&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DrawBuffer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;HOR_RES&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;VER_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;display&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Display&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;HOR_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;VER_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;refresh&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sim_display&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;draw_iter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;refresh&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// Define the initial state of your input&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;latest_touch_status&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PointerInputData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Touch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;released&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// Register a new input device that&apos;s capable of reading the current state of the input&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_touch_screen&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pointer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;latest_touch_status&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// Create screen and widgets&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;screen&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get_scr_act&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;screen&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;cstr&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Textarea&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;screen&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_align&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Align&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;TopMid&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;screen&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_align&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Align&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;TopMid&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;255u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s6&quot;&gt;// RGB565&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;dsc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl_sys&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;lv_img_dsc_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;h&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl_sys&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lv_img_header_t&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_cf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl_sys&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;LV_IMG_CF_TRUE_COLOR&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;IMG_RES&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;h&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;data_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ptr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;keyboard&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Keyboard&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;screen&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;keyboard&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;240&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;120&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;keyboard&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_textarea&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ev&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ValueChanged&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ev&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;unsafe&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ptr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl_sys&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;lv_textarea_get_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ptr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CStr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_ptr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ptr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string_lossy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_owned&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is_ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;unsafe&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl_sys&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;lv_img_set_src&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;dsc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;_&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;ffi&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;c_void&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;running&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;loop&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;start&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;task_handler&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sim_display&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;events&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;peekable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;in&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;events&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;match&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SimulatorEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;MouseButtonDown&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;mouse_btn&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;latest_touch_status&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PointerInputData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Touch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;pressed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SimulatorEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;MouseButtonUp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;mouse_btn&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;latest_touch_status&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;PointerInputData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Touch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;point&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;released&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SimulatorEvent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Quit&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;break&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;running&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_millis&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;lvgl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;tick_inc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;duration_since&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-28&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-28&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Makepad&lt;/h3&gt;&lt;p&gt;“&lt;a href=&quot;https://github.com/makepad/makepad&quot;&gt;Makepad&lt;/a&gt; is an AI-accelerated application and game development environment for Rust.”&lt;/p&gt;&lt;p&gt;I remember a year ago they weren’t saying that.&lt;/p&gt;&lt;p&gt;“It also has a large set of AI backends integrated for embedding llms or generative AI models inside applications or run them easily on local hardware”&lt;/p&gt;&lt;p&gt;That doesn’t sound like what a GUI framework should be doing.&lt;/p&gt;&lt;p&gt;Makepad’s link on Are We GUI Yet? points to a placeholder crate; their real crate name seems to be &lt;code&gt;makepad-widgets&lt;/code&gt;. But neither side has any documentation at all. Let me just hope I have better luck with their examples.&lt;/p&gt;&lt;p&gt;The examples in the repository don’t match the version published on crates.io. Moreover, it seems that Claude Code getting in on the act completely messed up their version management. Their git repository has two tags named &lt;code&gt;1.0.0&lt;/code&gt; and &lt;code&gt;Last1.0&lt;/code&gt;, and I can only infer from the dates which one corresponds to the version on crates.io.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/16c33dc4bf8b321d.png&quot; width=&quot;724&quot; height=&quot;944&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME only partially works: it can receive text input, but it doesn’t display the composer’s content. The screen reader cannot recognize the content in the window.&lt;/p&gt;&lt;p&gt;It seems their carefully designed DSL is intended for some kind of live editor, yet in their repository, there’s no documentation at all on how to install this editor.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;makepad_widgets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;live_design&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;widgets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Root&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;main_window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;body&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;View&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;flow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Down&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;spacing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;align&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;app_main&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Live&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LiveHook&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;live&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetRef&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LiveRegister&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;live_register&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;crate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;makepad_widgets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;live_design&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MatchEvent&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_startup&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_actions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Actions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;load_png_from_data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppMain&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;match_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;handle_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Scope&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-29&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-29&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Masonry&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/masonry/latest/masonry/&quot;&gt;Masonry&lt;/a&gt; is a foundational framework for building GUI libraries in Rust. Its goal is not to be a user-facing GUI framework, but rather to serve as a low-level framework for building GUI frameworks. They provide a widget tree and the means to render it. Frameworks built on masonry are free to choose their state management model, such as immediate mode, the Elm Architecture, or reactive programming.&lt;/p&gt;&lt;p&gt;Their documentation recommends users to use Xilem, a higher-level reactive GUI framework built on top of masonry. We’ll come back later to see what Xilem’s usage looks like. For now, let’s not follow their advice and instead see what it’s like to use masonry directly by hand.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/31edefabf3a1c64c.png&quot; width=&quot;876&quot; height=&quot;926&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;Both IME and screen reader work fine. For a GUI framework with pure Rust and custom-rendered widgets, this is quite impressive. Among all the GUI libraries I’ve tested so far, only egui has reached this level.&lt;/p&gt;&lt;p&gt;Without any configuration, masonry’s default font doesn’t support rendering CJK characters. I initially thought it might be like egui, where system fonts aren’t loaded, but after digging into it, I found that the issue is simply that its default font configuration doesn’t include CJK fonts. As long as you specify an appropriate font name when constructing the widget, it will render properly.&lt;/p&gt;&lt;p&gt;Masonry’s API feels very low-level indeed, but also very flexible. If the day ever comes when I need to build my own Rust GUI library (and if I actually do, I can’t decide whether that’s fortunate or unfortunate), masonry would be a good place to start; at least I’d get IME and accessibility support out of the box.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ErasedAction&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NewWidget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetTag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;parley&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontStack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;StyleProperty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;peniko&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageAlphaType&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;properties&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;types&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;widgets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Flex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Portal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextAction&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextArea&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry_winit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppDriver&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DriverCtx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NewWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry_winit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;winit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;TEXT_INPUT_TAG&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetTag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetTag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;text-input&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;LIST_TAG&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetTag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Flex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetTag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;list&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;WIDGET_SPACING&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Length&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;const_px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;5.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Driver&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppDriver&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Driver&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ctx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DriverCtx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_widget_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetId&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ErasedAction&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;is&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextAction&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;action&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;downcast&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextAction&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextAction&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;action&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;render_root&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ctx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render_root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_id&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;render_root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;edit_widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_image_data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;downcast&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;render_root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;edit_widget_with_tag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;LIST_TAG&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_auto_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_id&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Flex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add_child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;make_widget_tree&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NewWidget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NewWidget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NewWidget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new_with_tag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_text_area&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextArea&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new_editable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;StyleProperty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;FontStack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontStack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Source&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;system-ui, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_auto_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;TEXT_INPUT_TAG&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;list&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Flex&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_child&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_spacer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;WIDGET_SPACING&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NewWidget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Portal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NewWidget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new_with_tag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;LIST_TAG&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ImageLuma8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageData&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;alpha_type&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageAlphaType&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;AlphaPremultiplied&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window_attributes&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default_attributes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_resizable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;driver&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Driver&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image_id&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry_winit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_user_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry_winit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run_with&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;vec&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;NewWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window_attributes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;make_widget_tree&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;erased&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;driver&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default_property_set&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-30&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-30&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Maycoon&lt;/h3&gt;&lt;p&gt;“&lt;a href=&quot;https://crates.io/crates/maycoon&quot;&gt;Maycoon&lt;/a&gt; is shutting down!”&lt;/p&gt;&lt;p&gt;A few months ago, the author of Maycoon announced that Maycoon had been deprecated and deleted its GitHub repository. According to the author, “Rust simply is not a good fit to make a UI framework.” Let’s take a moment of silence for Maycoon, then move on to the next framework.&lt;/p&gt;&lt;h3 id=&quot;loc-31&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-31&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Pane UI&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/pane_ui&quot;&gt;Pane UI&lt;/a&gt; is a GUI framework that defines UIs in RON, renders them with wgpu, and supports hot reloading.&lt;/p&gt;&lt;p&gt;It does not adopt a reactive design; the RON data files used to define the UI are completely static. If you want to create dynamic content, you need to modify the UI through code at runtime. This is not really a bad idea, because before reactive programming was invented, this is how everyone did it, for example, Win32 UI and VCL.&lt;/p&gt;&lt;p&gt;Regarding the schema of the RON used to define UIs, Pane UI’s README contains a somewhat incomplete description, which alone is not enough to understand how components are defined. However, one can infer what the schema should look like from the Rust documentation of the module they use to parse RON, although even then the information is still not complete.&lt;/p&gt;&lt;p&gt;Unfortunately, Pane UI cannot accomplish this task, because it does not support creating and inserting images at runtime. Neither attempting to modify the properties of an existing image nor creating a new image component is supported in Pane UI. Perhaps there is also a hacky workaround: leveraging Pane UI’s hot reload mechanism to modify the RON file used to load the UI at runtime. But that sounds a bit too crazy.&lt;/p&gt;&lt;h3 id=&quot;loc-32&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-32&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Pax&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://www.pax.dev&quot;&gt;Pax&lt;/a&gt; is a GUI framework that emphasizes “designability”, combining a Figma-like designer with the program’s GUI. This sounds like a great idea, if it can actually work.&lt;/p&gt;&lt;p&gt;Pax’s desktop support is macOS only, and it is still in alpha. In my attempt, its macOS version failed to compile due to an internal parameter mismatch error. Given that Pax has not been updated for two years, I decided not to waste any more time on it.&lt;/p&gt;&lt;h3 id=&quot;loc-33&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-33&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Ply&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://plyx.iz.rs/docs/getting-started/&quot;&gt;Ply&lt;/a&gt; is also a newcomer to the Rust GUI framework scene this year. Its author published a &lt;a href=&quot;https://plyx.iz.rs/blog/introducing-ply/&quot;&gt;post&lt;/a&gt; on the Are We GUI Yet? blog list titled “building apps in Rust shouldn’t be this hard”. That’s certainly a good way to draw attention to a new project.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/d7b8dce04643e12b.png&quot; width=&quot;736&quot; height=&quot;890&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME does not work properly. After adding some additional code to set up accessibility, the screen reader can read the contents of the window.&lt;/p&gt;&lt;p&gt;In the blog post, the author talks about the pain points they encountered with other Rust GUI frameworks and then introduces ply’s builder-based API design. In practice, the code does feel more concise, and it plays well with editor autocompletion.&lt;/p&gt;&lt;p&gt;However, ply is not perfect in its API design. It adopts an immediate mode programming model, but the way it handles text box updates is through callbacks, which is somewhat problematic. To access external state inside the callback, I had to wrap it in &lt;code&gt;Rc&amp;lt;RefCell&amp;lt;T&gt;&gt;&lt;/code&gt;, because the callback may outlive the GUI builder. But from the perspective of the actual GUI lifecycle, this extra wrapping is unnecessary, since an immediate mode GUI’s lifetime is entirely confined to the rendering loop, and variables outside the loop should be freely accessible.&lt;/p&gt;&lt;p&gt;In addition, ply makes some odd choices for default values. For example, if you do not specify both &lt;code&gt;font_size&lt;/code&gt; and &lt;code&gt;color&lt;/code&gt; for your text, it will not display at all. I checked their documentation and found that the default &lt;code&gt;font_size&lt;/code&gt; is 0 and the default color is transparent, which is very counterintuitive. The default &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; of an element also appear to be 0, which is equally unintuitive.&lt;/p&gt;&lt;p&gt;Overall, ply is probably still a ways away from the goal it claims of “shouldn’t be this hard.”&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;ply_engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cell&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RefCell&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;rc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;window_conf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;macroquad&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Conf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;macroquad&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Conf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;miniquad_conf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;miniquad&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Conf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_owned&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window_width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;800&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;window_height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;600&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;high_dpi&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;sample_count&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Texture2D&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ImageLuma8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Texture2D&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;macroquad&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window_conf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;async&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;DEFAULT_FONT&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontAsset&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FontAsset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;assets/fonts/noto_sans_sc.ttf&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ply&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ply&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;DEFAULT_FONT&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RefCell&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Texture2D&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RefCell&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;loop&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clear_background&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;BLACK&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ply&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;grow&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;grow&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;direction&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TopToBottom&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;align&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CenterX&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CenterY&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;font_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;WHITE&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;accessible&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;grow&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;20.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;background_color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0x262220&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;corner_radius&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;6.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;font_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;borrow_mut&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;accessibility&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AccessibilityRole&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;TextInput&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;input&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;borrow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;fixed&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;fixed&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;next_frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-34&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-34&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;QMetaObject&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/qmetaobject/latest/qmetaobject/&quot;&gt;QMetaObject&lt;/a&gt; is another Rust binding for Qt. Compared with CXX-Qt, this library is somewhat less active, and its documentation is relatively insufficient. It uses a more customized macro approach to create subclasses of QObject in Rust and allows them to be used in QML. In this simple example, the experience in terms of complexity is roughly similar to CXX-Qt.&lt;/p&gt;&lt;p&gt;Since the UI is built entirely with Qt, the final result is identical to the CXX-Qt one, so there is no need to show screenshots here.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Engine&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cstr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cstr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qmetaobject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QObject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyObject&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qt_base_class&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;trait&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QObject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qt_property&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;WRITE&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;set_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qt_property&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;NOTIFY&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr_code_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr_code_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qt_signal&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyObject&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QString&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;min_dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;url&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;data:image/png;base64,{}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;general_purpose&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;STANDARD&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;qr_code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_code_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qml_register_type&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyObject&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;cstr&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;MyObject&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;cstr&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;MyObject&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;engine&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QmlEngine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;load_data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;r#&quot;
        import QtQuick 2.12
        import QtQuick.Controls 2.12
        import QtQuick.Window 2.12
        import MyObject 1.0

        ApplicationWindow {
            id: root
            height: 480
            title: qsTr(&quot;QR Code Generator&quot;)
            visible: true
            width: 640
            color: palette.window

            readonly property MyObject myObject: MyObject {}

            Column {
                anchors.fill: parent
                anchors.margins: 10
                spacing: 10

                Label {
                    text: qsTr(&quot;Enter text to generate QR code:&quot;)
                    color: palette.text
                }

                TextField {
                    placeholderText: qsTr(&quot;https://example.com&quot;)
                    onTextChanged: root.myObject.text = text
                }

                Image {
                    width: 256
                    height: 256
                    fillMode: Image.PreserveAspectFit
                    source: root.myObject.qr_code
                    visible: status === Image.Ready
                }
            }
        }
    &quot;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-35&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-35&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Relm&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/relm/&quot;&gt;Relm&lt;/a&gt; is a GUI framework based on GTK that uses the Elm Architecture as its programming model.&lt;/p&gt;&lt;p&gt;Relm uses GTK 3, which is said to be deprecated. But as I found in my earlier investigation, the GTK 3 library is still being quietly updated, and relm itself is also being quietly updated. It released a new version this year, upgrading to Rust 2024 Edition, but there were no significant changes in functionality.&lt;/p&gt;&lt;p&gt;Since the UI part is essentially GTK, there is no need to include screenshots for comparison again.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gdk_pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Colorspace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;glib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;relm&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;relm_derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;enum&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Quit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Widget&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Win&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;match&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;event&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;widgets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_from_pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Quit&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main_quit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Box&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;orientation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Orientation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vertical&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;spacing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Entry&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;img&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;delete_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Quit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;glib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Propagation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Proceed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ImageLuma8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_rgb8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Pixbuf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_owned&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Colorspace&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Rgb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;w&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;h&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;w&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Win&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Win::run failed&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-36&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-36&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Relm4&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/relm4/&quot;&gt;Relm4&lt;/a&gt; is the GTK 4 version of Relm. Apart from that, there doesn’t seem to be much to say. Developing applications with it is just as enjoyable as with Relm.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;relm4&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gdk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;relm4&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;glib&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;relm4&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;relm4&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Debug&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;enum&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;relm4&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;component&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SimpleComponent&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Init&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Output&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;set_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Box&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;set_orientation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Orientation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vertical&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;set_spacing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;set_label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Entry&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;connect_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sender&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sender&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gtk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Picture&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;set_width_request&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;set_height_request&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;watch&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;set_paintable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sender&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ComponentSender&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ComponentParts&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;model&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;widgets&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;view_output&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ComponentParts&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;widgets&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_sender&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ComponentSender&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DynamicImage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;ImageLuma8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_rgb8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryTexture&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;w&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;h&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MemoryFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;R8g8b8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;w&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;usize&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RelmApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;org.example.HelloWorld&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-37&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-37&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Ribir&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://ribir.org/docs/introduction&quot;&gt;Ribir&lt;/a&gt; is a reactive Rust GUI framework that claims to adopt a “non-intrusive declarative programming model.” By this they mean you can first develop the data model for your application, and then adapt the UI to it. In this process, you do not need to make any modifications to the already designed data model. Although I really don’t understand why this would actually be a problem, I feel that any well-designed GUI framework should be able to do this.&lt;/p&gt;&lt;p&gt;Since Ribir released version 0.3 in 2024, over the past two years it has prepared more than 60 alpha versions for 0.4. I don’t know what exactly has allowed the developers to hold off for such a long time, but it has also piqued my interest in its new version somewhat.&lt;/p&gt;&lt;p&gt;After briefly looking through its documentation, I found that Ribir uses rather obscure notation in its macro syntax. Without the help of AI, I would never have figured out that to insert an optional image into the component tree, I should use syntax like this:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s4&quot;&gt;@&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;pipe&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Its documentation spends a great deal of space explaining how this macro syntax works, but it doesn’t say a word about why it was designed this way.&lt;/p&gt;&lt;p&gt;Ribir’s documentation appears to be inconsistent with its implementation in some places. For example, the documentation for &lt;code&gt;Input&lt;/code&gt; mentions that it emits a &lt;code&gt;TextChangedEvent&lt;/code&gt;. However, this event does not actually exist; instead, text input changes should be handled in the &lt;code&gt;on_chars&lt;/code&gt; event. The documentation for the &lt;code&gt;Image&lt;/code&gt; component says it accepts WebP format images, but in reality it is even more restrictive: it can only accept WebP images with RGBA pixels. If images with other pixel formats are passed in, its GPU renderer will crash outright.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/4028ad32bbf3afef.png&quot; width=&quot;794&quot; height=&quot;856&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME works properly, which is good. But the screen reader cannot recognize the contents of the window.&lt;/p&gt;&lt;p&gt;Although I have been criticizing how cryptic its macro syntax is, that is from the perspective of a programmer. When it comes to conciseness, Ribir’s system is truly second to none. Among all the GUI frameworks I have surveyed so far, it seems to require the fewest lines of code. If Ribir could replace some of its notation with a more intuitive version, I would not hesitate to admit that this is a good design.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;ribir&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WebP&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;fn_widget&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Stateful&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;on_chars&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;and_then&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;@&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;pipe&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-38&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-38&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Rinf&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://cunarist.github.io/rinf/&quot;&gt;Rinf&lt;/a&gt; is another framework that uses Flutter as the interface for Rust programs. I first learned about Rinf because of the &lt;a href=&quot;https://www.reddit.com/r/rust/comments/191b2to/comment/kgvgspl/&quot;&gt;plagiarism controversy&lt;/a&gt; between it and Flutter Rust Bridge a few years ago. But now that the controversy has settled down, we can take a good look at this library.&lt;/p&gt;&lt;p&gt;According to rinf’s documentation, it recommends managing all application state in Rust, with Flutter used only for the UI. Specifically, it suggests using the Actor model in Rust to manage application state.&lt;/p&gt;&lt;p&gt;In this simple example, comparing the code written with rinf to Flutter Rust Bridge, it feels that under rinf’s model, I can write Flutter code in a way that is more idiomatic to Flutter. Data is passed from Flutter to Rust through asynchronous functions; state is computed and managed on the Rust side, and then passed back to Flutter as subscribable streams. In this process, all the models are ones that Flutter already has natively, unlike Flutter Rust Bridge, which reinvents a pattern for managing state in Flutter. Of course, this applies to cases where you want to manage all state on the Rust side. Flutter Rust Bridge, on the other hand, is probably better suited to scenarios where state is managed in Flutter, and Rust is used only to write functions that are called by Flutter.&lt;/p&gt;&lt;p&gt;Since the UI is the same as the Flutter Rust Bridge version, screenshots aren’t included here for comparison.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;p&gt;Rust:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Actor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Address&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Notifiable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;rinf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DartSignal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RustSignalBinary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;serde&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Deserialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Serialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Deserialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;DartSignal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextChanged&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Serialize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RustSignalBinary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCodeGen&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FirstActor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Actor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FirstActor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FirstActor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Address&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;spawn&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listen_to_dart&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;async&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;listen_to_dart&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Address&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;receiver&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextChanged&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get_dart_signal_receiver&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;while&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;signal_pack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;receiver&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;recv&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;await&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;signal_pack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;async_trait&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;async_trait&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Notifiable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextChanged&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FirstActor&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;async&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextChanged&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;encode_qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCodeGen&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;send_signal_to_dart&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;encode_qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Flutter:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;dart&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&apos;package:flutter/material.dart&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&apos;package:flutter_hooks/flutter_hooks.dart&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&apos;package:rinf/rinf.dart&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&apos;src/bindings/bindings.dart&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Future&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;async&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;await&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;initializeRust&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;assignRustSignal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;runApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;class&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyApp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;extends&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;HookWidget&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MyApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

  &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;override&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Widget&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;BuildContext&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;final&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;useStream&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCodeGen&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;rustSignalStream&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;?.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;binary&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;MaterialApp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&apos;QR Code Generator&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ThemeData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;colorScheme&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;seedColor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Colors&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;indigo&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;home&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Scaffold&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
          &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextField&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
              &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;onChanged&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextChanged&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;sendSignalToRust&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;memory&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
          &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-39&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-39&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Rosin&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/rosin/latest/rosin/&quot;&gt;Rosin&lt;/a&gt; is also a GUI framework that emerged in 2026. Like the Elm Architecture, it centralizes all state at the top of the program. However, unlike Elm, it uses fine-grained reactivity to handle state updates. In addition, it supports styling programs with CSS, which is indeed a novel approach for a GUI library that draws its own widgets.&lt;/p&gt;&lt;p&gt;I originally thought rosin could not accomplish this task, because it has no image widget and does not support loading images in CSS background-image either. But when I tried the next framework, rui, which requires manual drawing on a canvas, I was inspired. So I went back and re-examined rosin’s API. I discovered that rosin provides an &lt;code&gt;on_canvas&lt;/code&gt; method for each component node, which exposes the vello context used for drawing that node, so I can manually draw images in it.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/76638d88ab5b78ee.png&quot; width=&quot;716&quot; height=&quot;884&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME works properly, and after adding some code to set up accessibility, the screen reader can also recognize the contents of the window. This is quite a good achievement for a framework that is just getting started.&lt;/p&gt;&lt;p&gt;However, rosin still has a ways to go. The current model allows for highly flexible custom components, but the built-in components are still not very rich. Also, rosin’s default styles strongly assume dark mode. If you don’t separately style a text box, its default font color is unreadable against its default background.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;FromStr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;rosin&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;kurbo&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Affine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;peniko&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Blob&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageAlphaType&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageBrush&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageQuality&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;widgets&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Stylesheet&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextBox&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Var&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Stylesheet&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;.input { color: #fff; font-family: Hiragino Sans GB; }&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextBox&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Var&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowHandle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;downgrade&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;style_sheet&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_accessibility&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_role&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;rosin&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;accesskit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Role&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;input&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;downgrade&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;classes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;input&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;draw_qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get_or&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;draw_qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CanvasCtx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;padding_box&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageData&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Blob&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;alpha_type&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageAlphaType&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Alpha&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;scale&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;/&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;scene&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;draw_image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageBrush&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_quality&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageQuality&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Low&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Affine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;scale&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;scale&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowDesc&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;main_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppLauncher&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TranslationMap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Failed to launch&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-40&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-40&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Rui&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/rui/latest/rui/&quot;&gt;Rui&lt;/a&gt; is an “experimental declarative UI library.” It has been over three years since rui’s last release, and it is a pity to see it still in an experimental state. However, I noticed that rui’s GitHub repository became active again last year, and perhaps we will see its next version soon.&lt;/p&gt;&lt;p&gt;Rui’s design is inspired by SwiftUI and adopts a reactive programming model. Rui was created by the author to port their music workstation Audulus to Rust. Although Audulus is not open source, I cannot know its specific implementation. However, based on the fact that it is available on the App Store, as well as other discussions in the rui documentation, I infer that Audulus was developed with SwiftUI.&lt;/p&gt;&lt;p&gt;In the README, the author mentions some of the rationale behind rui’s design. For example, SwiftUI’s extensive texture caching is no longer necessary on modern GPUs, while for lightweight tasks such as layout, although they cannot be accelerated by the GPU, there is no need to cache them in the widget tree. Although I had a hard time understanding this long passage because I have no experience developing GUI frameworks, it is always a good thing to see the author actively communicating their design rationale.&lt;/p&gt;&lt;p&gt;However, rui does not have an image widget; it only has a canvas that can draw using vector operations. So I need to convert the QR code into a series of drawing commands and then draw them onto rui’s canvas.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/e3296ce4805e0c63.png&quot; width=&quot;916&quot; height=&quot;1304&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;Neither IME nor screen reader is supported. After analyzing rui’s source code with AI, I found that rui’s accessibility support is only partially implemented. They generate accessibility information for widget nodes, but do not submit it to the system.&lt;/p&gt;&lt;p&gt;For such a simple task, rui’s code is extremely concise. I feel that if rui could add support for pixel images, this task could even be completed in under 20 lines.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;vstack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Auto&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_editor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Auto&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_code_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Auto&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;window_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_code_view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;View&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;modules&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_colors&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;vger&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;/&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;n&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f32&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;8.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;vger&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;color_paint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;WHITE&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;vger&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;color_paint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;BLACK&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;vger&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fill_rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;in&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;modules&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;iter&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;color&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;==&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Dark&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;i&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;%&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;i&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;/&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;p&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;origin&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LocalOffset&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;x&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f32&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;4.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;n&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;3&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f32&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;vger&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fill_rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LocalRect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LocalSize&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;280.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;280.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-41&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-41&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;SDL3&lt;/h3&gt;&lt;p&gt;The &lt;a href=&quot;https://docs.rs/sdl3/latest/sdl3/&quot;&gt;sdl3&lt;/a&gt; crate is a Rust binding for the well-known graphics library SDL3. It is a bit strange to include this crate in Are We GUI Yet?, because it can hardly be considered a GUI framework. It merely provides a canvas on which you can draw freely. Although you can draw the widgets you want in it, you need to implement layout, event handling, state management, and other functionality yourself, none of which SDL3 can provide for you.&lt;/p&gt;&lt;p&gt;Rather than Are We GUI Yet?, SDL3 should appear in Are We Game Yet? &lt;sup&gt;10&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;10.&lt;/span&gt;&lt;span&gt;It &lt;a href=&quot;https://arewegameyet.rs/ecosystem/2drendering/&quot;&gt;indeed is&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt; instead.&lt;/p&gt;&lt;h3 id=&quot;loc-42&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-42&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Slint&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://slint.dev/docs&quot;&gt;Slint&lt;/a&gt; is a GUI framework that I have always been very fond of; it can basically be considered the Rust version of Qt. It supports multiple platforms such as desktop, mobile, embedded, and Web, and provides bindings for C++, Rust, Node.js, and Python.&lt;/p&gt;&lt;p&gt;Slint uses a dedicated language also called slint as a DSL for writing UIs, which is almost identical to QML in this respect. It also adopts a reactive model based on two-way bindings. Designing a dedicated language to describe GUIs has both advantages and disadvantages compared with keeping all the logic in the host language. The advantage is that you can have syntax and semantics that are better suited to describing GUIs. Another benefit is that you can build an ecosystem around the language itself, such as interface editors, live previews&lt;sup&gt;11&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;11.&lt;/span&gt;&lt;span&gt;Slint’s live previewer is quite handy; it would be even better if it could support displaying CJK characters.&lt;/span&gt;&lt;/span&gt;, and so on. The disadvantage is that cross-language interaction inevitably introduces friction, especially when logic and state are tightly coupled, requiring you to switch frequently between the two languages.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/fbad7ac9236af6a3.png&quot; width=&quot;656&quot; height=&quot;800&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;Both IME and screen reader work properly.&lt;/p&gt;&lt;p&gt;Slint’s VS Code extension can provide code completion and preview support for slint files, and even for slint code snippets embedded in Rust via slint macros. This is undoubtedly a great boost to the developer experience.&lt;/p&gt;&lt;p&gt;In community discussions on Reddit, slint is not as popular as iced or egui. Considering how complete its feature set is, I feel slint deserves more traction. Part of the reason may be that slint adopts a semi-commercial open-source licensing model similar to Qt’s. But this is actually a common practice in the open-source software world, and we shouldn’t be overly critical of normal commercial behavior.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;slint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgb8Pixel&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SharedPixelBuffer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;slint&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;slint&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;!&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;VerticalBox&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;from&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;std-widgets.slint&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;export&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;component&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;inherits&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Window&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;out&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;property&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;out&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;property&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;callback&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;changed&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;VerticalBox&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextInput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgb&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buffer&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SharedPixelBuffer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgb8Pixel&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone_from_slice&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_rgb8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AppWindow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui_handle&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_weak&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_text_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui_handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;upgrade&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-43&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-43&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Tauri&lt;/h3&gt;&lt;p&gt;People often describe &lt;a href=&quot;https://tauri.app/&quot;&gt;Tauri&lt;/a&gt; as a lightweight Electron written in Rust.&lt;/p&gt;&lt;p&gt;Tauri emerged around the same time as Windows WebView2. Its original goal was to solve the problem of Electron apps bundling an entire Chrome browser and taking up a large amount of disk space. Because Tauri uses the system WebView directly, Tauri apps can be kept very small.&lt;/p&gt;&lt;p&gt;However, Tauri still inherits all the drawbacks of WebView, such as high memory usage and the unavoidable IPC and cross-language friction between the browser and the backend.&lt;/p&gt;&lt;p&gt;Since Tauri can indeed be used to build GUIs for Rust programs, people often compare it with other GUI frameworks. But I think this comparison is somewhat risky. Before you even decide to add a GUI to a program, whether to choose a Web UI is a fundamental fork in the road. State management is usually tightly coupled with the interface. Once you choose a Web UI, you have to start thinking about managing program state on the frontend. And the frontend is often a different language; even if you write the frontend in Rust, you still need to consider the IPC boundary between frontend and backend.&lt;/p&gt;&lt;p&gt;Boringcactus sharply criticized the type safety of Tauri IPC in hir post. Ze then mentioned that ze learned at the Utah Rust meetup about a project called tauri-specta that can improve IPC type safety between Rust and TypeScript. Although this is a survey about Rust GUIs, and writing the interface in TypeScript may be somewhat off-topic, let’s still take a look at how much tauri-specta can improve type safety.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/4775d439f63b8880.png&quot; width=&quot;774&quot; height=&quot;1022&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;There’s nothing much to say about the interface; both IME and screen reader work properly.&lt;/p&gt;&lt;p&gt;The way tauri-specta works is simpler than expected. It collects every function annotated with &lt;code&gt;#[specta]&lt;/code&gt;, parses its type, and exports it in a TypeScript stub file. This stub file contains typed wrappers for Tauri IPC, allowing correct types to be used in TypeScript. Although it sounds simple, it is indeed an effective approach. It would be great if the Tauri team could integrate this solution into their system.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;p&gt;Rust:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;specta_typescript&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Typescript&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tauri_specta&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;collect_commands&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tauri&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;specta&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;specta&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;generate_qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode_data_url&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map_err&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode_data_url&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;min_dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;b64&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;general_purpose&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;STANDARD&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;data:image/png;base64,{b64}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;builder&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tauri&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Wry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;collect_commands&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;generate_qr_code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;builder&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Typescript&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;../src/bindings.ts&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Failed to export typescript bindings&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tauri&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;invoke_handler&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;invoke_handler&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mount_events&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tauri&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;generate_context&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;error while running tauri application&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;TypeScript:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;tsx&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;useState&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;from&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;react&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;import&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;commands&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;from&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;./bindings&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;function&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;setQrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

  &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;generateQrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;status&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;===&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;ok&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;setQrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;main&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;flex&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;flexDirection&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;1rem&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;1rem&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;Enter text to generate QR code:&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;input&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;greet-input&quot;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;currentTarget&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;https://example.com&quot;&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;/&gt;&lt;/span&gt;&lt;span&gt;
      &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Generated QR Code&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;/&gt;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;hl-s7&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;export&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;default&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-44&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-44&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Tessera&lt;/h3&gt;&lt;p&gt;“&lt;a href=&quot;https://docs.rs/tessera-ui/latest/tessera_ui/&quot;&gt;Tessera&lt;/a&gt; is a declarative, immediate-mode UI framework for Rust that emphasizes performance, flexibility, and extensibility through a functional approach and pluggable shader system.”&lt;/p&gt;&lt;p&gt;Tessera is also a very new UI framework. Its first version was released in July 2025, and it has now reached version 2.5.0. According to a &lt;a href=&quot;https://tessera-ui.github.io/blog/positional-memoization-via-proc-macros.html&quot;&gt;blog post&lt;/a&gt; included in its documentation, Tessera is working on implementing Material Design as a milestone for version 3.0. From that blog post, I get the impression that Tessera has some unique insights into state management for immediate mode GUIs.&lt;/p&gt;&lt;p&gt;However, when I tried it, Tessera could not run on macOS, encountering some errors from wgpu. Hopefully, once it fixes its platform compatibility, we can meet again someday.&lt;/p&gt;&lt;h3 id=&quot;loc-45&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-45&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Tinyfiledialogs&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/tinyfiledialogs/latest/tinyfiledialogs/&quot;&gt;Tinyfiledialogs&lt;/a&gt; provides a Rust binding for a C library that offers various small dialogs. It cannot be considered a complete GUI framework, but it does provide some GUI functionality. Its features are not sufficient to accomplish today’s task.&lt;/p&gt;&lt;p&gt;A crate with a similar positioning is &lt;a href=&quot;https://docs.rs/rfd/latest/rfd/&quot;&gt;rfd&lt;/a&gt;, but it is not included on Are We GUI Yet?.&lt;/p&gt;&lt;h3 id=&quot;loc-46&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-46&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Tk&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/tk/latest/tk/&quot;&gt;Tk&lt;/a&gt; is the Rust binding for Tcl/Tk. I suspect most people’s first exposure to Tcl/Tk comes from the rather idiosyncratic tkinter module in Python’s standard library.&lt;/p&gt;&lt;p&gt;Although Python’s standard library bundles Tk 8.6, using the Tk crate requires having Tk 8.6 installed on your system beforehand. If the version is mismatched – for instance, on my first attempt, the system Tk on macOS was 8.5, which led to some strange compilation errors.&lt;/p&gt;&lt;p&gt;The Tk crate employs clever operator overloading to faithfully replicate the distinctive syntax of Tk commands. If you have a genuine fondness for the Tcl language, you’ll appreciate this design. However, what would likely suit most developers better is to use the host language idiomatically, as Python’s tkinter does. In Rust, for example, the builder pattern would be a more natural fit.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/93a49d840d154c79.png&quot; width=&quot;696&quot; height=&quot;854&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME works properly, but the screen reader cannot recognize the contents of the window. This is somewhat disappointing, since Tcl/Tk is a long-established UI toolkit and one would expect it to be mature in all respects. However, its age may be a factor: accessibility was not yet a consideration when it was originally designed.&lt;/p&gt;&lt;p&gt;As for the development experience with the Tk crate, despite the author’s thorough tutorial, it still falls short of covering everything needed for real-world GUI development. During development, I found it easier to consult Python’s tkinter documentation instead. The crate also contains several patterns that are quite unidiomatic in Rust. For instance, the &lt;code&gt;tclosure&lt;/code&gt; macro matches closure parameters by name, so an incorrect parameter name results in a runtime error. This was not at all obvious when I first wrote the code.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Engine&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;tcl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;tk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Luma&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write_to&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cursor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Png&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;general_purpose&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;STANDARD&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TkResult&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;tk&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;make_tk&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;tk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_wm_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add_ttk_label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;pack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr_image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;tk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image_create_photo&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;qr&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;update&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;tcl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;tclosure&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;tk&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;vldt_new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TkResult&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;interp&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;tcl_interp&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;vldt_new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;interp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;qr&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;configure&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;-data&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;interp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;qr&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;blank&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add_ttk_entry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;validate&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;key&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;validatecommand&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;pack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add_ttk_label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;preview&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr_image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;pack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main_loop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-47&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-47&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Undoredo&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/undoredo&quot;&gt;Undoredo&lt;/a&gt; is not a GUI library. It provides incremental updates, snapshots, and rollback capabilities for various container data structures.&lt;/p&gt;&lt;p&gt;I suspect it is listed on Are We GUI Yet? because it can be used to implement state management in GUI applications. However, placing it alongside other GUI libraries still feels somewhat out of place. Are We GUI Yet? should seriously consider categorizing the crates on its site, similar to how Are We Game Yet? does.&lt;/p&gt;&lt;h3 id=&quot;loc-48&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-48&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Vizia&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.vizia.dev/vizia/&quot;&gt;Vizia&lt;/a&gt; is a declarative Rust GUI framework built on a fine-grained reactivity model, with skia as its rendering backend.&lt;/p&gt;&lt;p&gt;I ran into a few hurdles while implementing today’s task with Vizia. Vizia does provide an &lt;code&gt;Image&lt;/code&gt; widget, but it is not fully implemented. Although &lt;code&gt;Image&lt;/code&gt; accepts a &lt;code&gt;Signal&lt;/code&gt; as a parameter, it is not reactive; it only reads the state once at creation. Moreover, while the documentation states that &lt;code&gt;Image&lt;/code&gt; can load URLs, examining the implementation revealed that data URLs are not supported. As a result, I had to use the SVG widget to render the QR code instead. Unfortunately, the SVG widget has the same reactivity limitation, so I had to wrap the entire widget in a &lt;code&gt;Binding&lt;/code&gt; to make it respond to &lt;code&gt;Signal&lt;/code&gt; changes and trigger redraws.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/ec85cf8f8b3258bc.png&quot; width=&quot;760&quot; height=&quot;898&quot; style=&quot;display: block; width: 25em&quot;&gt;&lt;p&gt;IME works correctly, but when I tried to use a screen reader to inspect the window contents, the program crashed immediately.&lt;/p&gt;&lt;p&gt;This was quite unexpected. With the help of AI, I traced the cause of the crash. In the &lt;code&gt;Textbox&lt;/code&gt;’s &lt;code&gt;on_edit&lt;/code&gt; event, modifying the &lt;code&gt;Signal&lt;/code&gt; that the text widget itself listens to leaves some internal accessibility information stale. When the screen reader then tries to access it, an out-of-bounds access occurs. The workaround is to avoid passing a listenable signal to the &lt;code&gt;Textbox&lt;/code&gt;. However, that introduces another bug: when the text box loses focus, its content disappears because the state update is not propagated back to the widget. This looks like a catch-22. If you handle the state correctly, the screen reader breaks. But if you make the screen reader work, the text box’s state cannot be managed properly.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;vizia&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_svg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;renderer&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;svg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;min_dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Signal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Signal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;VStack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Textbox&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_edit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_svg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Binding&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Svg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Pixels&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;transparent&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;hoverable&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;alignment&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Alignment&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Center&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;inner_size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-49&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-49&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;WebRender&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/webrender/latest/webrender/&quot;&gt;WebRender&lt;/a&gt; is the rendering engine behind Mozilla Firefox and Servo, the browser written in Rust. Its documentation on docs.rs is severely outdated and gives little sense of the library’s actual state. I can’t help but wonder how the Servo developers manage to work under such conditions.&lt;/p&gt;&lt;p&gt;WebRender provides only drawing APIs, and as its wiki notes, these are specialized for browser use cases, which makes it difficult to use the library as a general-purpose GUI framework.&lt;/p&gt;&lt;h3 id=&quot;loc-50&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-50&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Windows&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://microsoft.github.io/windows-docs-rs/&quot;&gt;Rust for Windows&lt;/a&gt; is a highly ambitious project. Microsoft aims to provide comprehensive Rust bindings for the entire Windows API surface. By using the &lt;code&gt;windows&lt;/code&gt; crate, and the &lt;code&gt;windows-sys&lt;/code&gt; crate as supplementary, you can call any Windows API directly from Rust. This naturally includes the various GUI frameworks available on Windows, such as Win32 UI and Composition UI.&lt;/p&gt;&lt;p&gt;Calling Windows APIs directly to create GUI interfaces is far too tedious. Even a decade or more ago, nobody would have done such a thing. However, the Rust for Windows repository recently gained a new framework called &lt;code&gt;windows-reactor&lt;/code&gt;, which provides a reactive programming layer on top of WinUI 3, making it as convenient to develop with as other Rust GUI frameworks. I’m somewhat curious about it, so let me spin up a Windows VM and see what the development experience with &lt;code&gt;windows-reactor&lt;/code&gt; is like.&lt;/p&gt;&lt;h3 id=&quot;loc-51&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-51&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Windows Reactor&lt;/h3&gt;&lt;p&gt;Though &lt;a href=&quot;https://github.com/microsoft/windows-rs/tree/master/crates/libs/reactor&quot;&gt;Windows Reactor&lt;/a&gt; is not listed on Are We GUI Yet?, I decided to try it anyway, both for the reasons above and out of curiosity.&lt;/p&gt;&lt;p&gt;Windows Reactor’s state management model is nearly identical to React’s. It replicates hooks like &lt;code&gt;useState&lt;/code&gt; and &lt;code&gt;useRef&lt;/code&gt;, and, like React, it stores hook data according to call order. Since Dioxus, another React-inspired library, has moved toward a signal-based reactivity model, Windows Reactor is arguably now the Rust GUI library that most closely resembles React.&lt;/p&gt;&lt;p&gt;Overall, its API surface is relatively complete, but there are still some rough edges. For instance, to display an in-memory image, I had to create a canvas and draw the bitmap onto it. Initially, I assumed I would need to use Direct2D APIs directly for drawing. Later, with AI assistance, I found that the &lt;code&gt;windows-canvas&lt;/code&gt; crate offers a simpler interface for this purpose.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/b714fa7475b404fc.png&quot; width=&quot;628&quot; height=&quot;692&quot; style=&quot;display: block; width: 20em&quot;&gt;&lt;p&gt;IME input works as expected. Windows Narrator can read the contents of text boxes but fails to recognize text labels. I’m unsure whether this is because I didn’t set the appropriate accessibility flags in the code, or because Windows Reactor’s accessibility support is still incomplete.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;windows_canvas&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ColorF&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;GpuDevice&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;windows_reactor&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;RenderCx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Element&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;set_image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;use_state&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageSource&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;vstack&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_block&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_box&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_text_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;set_image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build_qr_surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or_default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;spacing&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build_qr_surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageSource&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;device&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;GpuDevice&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new_or_warp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;surface&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;CanvasImageSource&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;draw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ColorF&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;WHITE&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;session&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;session&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;draw_bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;session&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;create_bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rect&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_xywh&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;f32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;image_source&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;windows_core&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;bootstrap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-52&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-52&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;WinSafe&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/winsafe/latest/winsafe/&quot;&gt;WinSafe&lt;/a&gt; is a Rust binding for the Win32 API, and it offers a high-level, idiomatic abstraction layer for Win32 GUI programming. Interestingly, this library has no dependencies, not even the &lt;code&gt;windows&lt;/code&gt; crate, since WinSafe’s history predates it.&lt;/p&gt;&lt;p&gt;Now that I have a Rust development environment set up in the Windows VM, let’s give this library a try as well.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/0601b9db15ec24eb.png&quot; width=&quot;454&quot; height=&quot;628&quot; style=&quot;display: block; width: 20em&quot;&gt;&lt;p&gt;The UI has the familiar, reassuring Win32 look. Both the screen reader and IME work flawlessly.&lt;/p&gt;&lt;p&gt;While most of WinSafe’s API can be used from safe Rust, a few features still lack safe wrappers and require calling the underlying Win32 APIs through &lt;code&gt;unsafe&lt;/code&gt; code. Setting the image on a Label in this task is one such case.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cell&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cell&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;winsafe&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;self&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;AnyResult&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;wnd&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowMain&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowMainOpts&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dpi&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;224&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;283&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;wnd&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LabelOpts&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dpi&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Edit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;wnd&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EditOpts&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dpi&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;41&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dpi_x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;wnd&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;LabelOpts&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dpi&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;71&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dpi&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;control_style&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;co&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;SS&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;BITMAP&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;co&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;SS&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;CENTERIMAGE&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;edit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bitmap&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Cell&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;en_change&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;next&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;edit&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;max_dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dpi_x&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;gui&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dpi_y&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bits&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;HBITMAP&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;CreateBitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;SIZE&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;as&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bits&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_mut_ptr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;transpose&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;handle&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;unsafe&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_deref&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;unwrap_or&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;HBITMAP&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;raw_copy&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;unsafe&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;hwnd&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;SendMessage&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;StmSetImage&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;BmpIconCurMeta&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Bmp&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;wnd&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run_main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-53&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-53&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;WxDragon&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/wxdragon/latest/wxdragon/&quot;&gt;WxDragon&lt;/a&gt; is a Rust binding for wxWidgets, a widely used GUI toolkit. Considering wxWidgets’ prominence in the Python ecosystem, it is somewhat surprising that a Rust binding did not appear until 2025.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/d478a243daecb2d1.png&quot; width=&quot;690&quot; height=&quot;780&quot; style=&quot;display: block&quot;&gt;&lt;p&gt;Both IME input and screen reader functionality work as expected.&lt;/p&gt;&lt;p&gt;Apart from wxWidgets’ somewhat idiosyncratic widget naming conventions, there is little to fault in this binding. Despite being relatively new, it already covers virtually every aspect of wxWidgets. Since wxWidgets itself is a mature toolkit, I see no issue with using this binding in a production environment.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wxdragon&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;prelude&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;from_rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;dyn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wxdragon&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_title&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sizer&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;BoxSizer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Orientation&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Vertical&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;StaticText&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sizer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SizerFlag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;AlignCenterHorizontal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;TextCtrl&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sizer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SizerFlag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;AlignCenterHorizontal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;StaticBitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sizer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;SizerFlag&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;AlignCenterHorizontal&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;on_text_changed&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;move&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ev&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ev&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;get_string&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;and_then&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
                &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_bitmap&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;qr&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;set_sizer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;sizer&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-54&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-54&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Xilem&lt;/h3&gt;&lt;p&gt;Finally, we are almost at the tail end of this list.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/xilem/latest/xilem/&quot;&gt;Xilem&lt;/a&gt; is a reactive Rust GUI framework built on the previously mentioned Masonry, and it provides a reactive user-interface layer on top of it.&lt;/p&gt;&lt;p&gt;Xilem has a &lt;a href=&quot;https://raphlinus.github.io/rust/gui/2022/05/07/ui-architecture.html&quot;&gt;blog post&lt;/a&gt; explaining their understanding of implementing reactive GUI interfaces in Rust. It is an excellent article and is very helpful for understanding reactive GUI frameworks, as well as why many Rust GUI frameworks are designed the way they are. After reading it, I did see traces of the ideas proposed by Xilem in some of the frameworks I encountered in this survey, such as how blinc and KAS handle stateful components.&lt;/p&gt;&lt;p&gt;Floem mentions in its documentation that it was also influenced by Xilem, and Xilem says in its blog that its design was influenced by rui. I think it would be interesting if someone could organize the relationships of mutual influence among these Rust GUI frameworks into a diagram similar to a biological evolutionary tree.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/6685c53e5bb54189.png&quot; width=&quot;806&quot; height=&quot;954&quot; style=&quot;display: block&quot;&gt;&lt;p&gt;Like the underlying Masonry, IME and screen reader are both available. However, because Xilem does not expose Masonry’s interface for setting the font for text input, CJK characters in text input cannot be displayed correctly.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Full Code&lt;/summary&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;xilem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;masonry&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;peniko&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageAlphaType&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;xilem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;flex_col&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;xilem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetView&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowOptions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Xilem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageData&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;qrcode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;QrCode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;as_bytes&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Rgba&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageData&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageFormat&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Rgba8&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;alpha_type&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;ImageAlphaType&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;AlphaPremultiplied&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;app_logic&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WidgetView&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;flex_col&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;Enter text to generate QR code:&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;text_input&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;new_text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;qr_encode&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;anyhow&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Xilem&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new_simple&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app_logic&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;WindowOptions&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;&quot;QR Code Generator&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;run_in&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;EventLoop&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;with_user_event&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;)&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h3 id=&quot;loc-55&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#loc-55&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Yew&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://docs.rs/yew/&quot;&gt;Yew&lt;/a&gt; is a React-style framework for developing web apps, and like Leptos, it does not have native desktop GUI support.&lt;/p&gt;&lt;h3 id=&quot;conclusion&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#conclusion&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Conclusion&lt;/h3&gt;&lt;p&gt;Well, it is time to bring this long journey to a close and, in doing so, single out the winners of this survey, or, to put it more modestly, the frameworks I would be willing to use.&lt;/p&gt;&lt;p&gt;In the winners’ circle are slint and egui (&lt;em&gt;edit on 2026-08-25: and GPUI Component&lt;/em&gt;). Beyond having APIs free of obvious friction or pitfalls, they also provide solid support for IME and accessibility. They respectively occupy the two thrones of retained-mode UI and immediate-mode UI.&lt;/p&gt;&lt;p&gt;There are also frameworks that appeal to me in certain niche areas. For example, Crux paired with SwiftUI, and rinf paired with Flutter. And if I were willing to adopt a WebView, Dioxus or Tauri + &lt;code&gt;tauri-spectra&lt;/code&gt; would be reasonable choices.&lt;/p&gt;&lt;p&gt;Other frameworks fall just short of the winners’ circle due to minor drawbacks, cushy, Freya, Floem, Iced, Relm4, and Xilem, for instance. I also find their API designs quite appealing. Unfortunately, they are somewhat lacking in input method or accessibility support. Should they continue to improve in these areas, their future looks promising.&lt;/p&gt;&lt;p&gt;Of course, this survey is only a snapshot, and a rather subjective one. A framework that excels in this simple scenario may not necessarily handle more complex programs. Still, this exercise exposed the parts of GUI development that are hardest to fake. Rust has plenty of promising GUI projects, but the ecosystem has not yet converged on a universally accepted, boring choice.&lt;/p&gt;&lt;p&gt;I may also have made mistakes in this survey due to personal oversights. If you find anything I have written that does not match the facts, please contact me and point it out.&lt;/p&gt;&lt;details&gt;&lt;summary&gt;Curious about the disk space this survey used?&lt;/summary&gt;&lt;pre&gt;&lt;code data-lang=&quot;shell&quot;&gt;&lt;span&gt;$ dust -d 1 .
213M   ┌── windows-rs               │█           │   0%
292M   ├── hello-qmetaobject        │█           │   0%
568M   ├── hello-cacao              │█           │   1%
597M   ├── hello-fltk               │█           │   1%
659M   ├── hello-makepad            │█           │   1%
744M   ├── hello-relm4              │█           │   1%
769M   ├── hello-gtk4               │█           │   1%
786M   ├── hello-tk                 │█           │   1%
923M   ├── hello-ply                │█           │   1%
939M   ├── hello-azul               │█           │   1%
1.0G   ├── hello_flutter_rust_bridge│█           │   1%
1.2G   ├── hello-relm               │█           │   1%
1.5G   ├── hello_rinf               │█           │   2%
1.6G   ├── hello-lvgl               │█           │   2%
1.6G   ├── hello-cxx-qt             │█           │   2%
1.7G   ├── hello-floem              │█           │   2%
1.8G   ├── hello-cushy              │█           │   2%
1.8G   ├── hello-fui                │█           │   2%
1.8G   ├── hello-pane-ui            │█           │   2%
1.8G   ├── hello-dioxus             │█           │   2%
1.9G   ├── hello-gtk                │█           │   2%
1.9G   ├── azul                     │█           │   2%
1.9G   ├── hello-egui               │█           │   2%
2.1G   ├── hello-xilem              │█           │   2%
2.1G   ├── hello-gemgui             │█           │   2%
2.1G   ├── hello-imgui              │█           │   2%
2.2G   ├── hello-masonry            │█           │   2%
2.2G   ├── hello-rui                │█           │   2%
2.4G   ├── hello-tessera            │█           │   3%
2.5G   ├── hello-freya              │█           │   3%
2.8G   ├── hello-pax                │█           │   3%
2.8G   ├── hello-iced               │█           │   3%
3.0G   ├── hello-kas                │█           │   3%
3.4G   ├── hello-vizia              │█           │   4%
3.9G   ├── hello-rosin              │█           │   4%
4.2G   ├── hello-slint              │█           │   4%
4.6G   ├── hello-tauri              │█           │   5%
4.6G   ├── hello-wxdragon           │█           │   5%
5.0G   ├── hello-blinc              │█           │   5%
5.1G   ├── hello-crux               │█           │   5%
5.7G   ├── hello-gpui               │█           │   6%
6.1G   ├── hello-ribir              │█           │   6%
 94G ┌─┴ .                          │███████████ │ 100%&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/details&gt;&lt;details&gt;&lt;summary&gt;Some extra words about the user interface design&lt;/summary&gt;&lt;p&gt;GUI is a discipline of composition. A GUI consists of many components, each with its own functionality, and the framework’s job is to ensure that, when combined, they can cooperate to deliver more complete functionality. This involves many forms of composition: component with component, component with state, and state with state.&lt;/p&gt;&lt;p&gt;The manner of composition determines the shape of the user interface, because different components and different states typically have different types. To compose values of different types together, some non-trivial design is always required, whether through tuples or similar combinators (cushy, floem, xilem), through an imperative approach of inserting components into the interface one at a time (egui, rosin, vizia), through a degree of macro magic (iced, KAS, ribir), or even by inventing a dedicated language (slint).&lt;/p&gt;&lt;p&gt;Some may argue that in 2026, with coding agents all the rage, interface designs no longer need to prioritize human readability. But that is no excuse for a framework author to abandon their aesthetic exploration. Only with a thorough, holistic understanding of the entire system’s design, and from a high-level perspective, can one produce a user interface that is both concise and elegant. If a library offers only interfaces riddled with friction or obscurity, one may rightly question whether its author has made a genuine effort to explore this field.&lt;/p&gt;&lt;/details&gt;&lt;h3 id=&quot;the-table&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rust-gui-survey-2026/#the-table&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;The Table&lt;/h3&gt;&lt;p&gt;&lt;em&gt;Edit on 2026-08-25: Added extra dependencies column.&lt;/em&gt;&lt;/p&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Library&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Usability&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Extra Deps&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Accessibility&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;IME Support&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://azul.rs&quot;&gt;Azul&lt;/a&gt;&lt;/td&gt;&lt;td&gt;😭 cannot read fonts&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://project-blinc.github.io/Blinc&quot;&gt;blinc&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 API friction&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;🟡 composer position bad; CJK fonts unsupported&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/cacao/latest/cacao/&quot;&gt;cacao&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;macOS only&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/core-foundation/latest/core_foundation/&quot;&gt;Core Foundation&lt;/a&gt;&lt;/td&gt;&lt;td&gt;😭 low-level API&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://redbadger.github.io/crux/&quot;&gt;Crux&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;SwiftUI&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/cushy/latest/cushy/&quot;&gt;cushy&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;🟡 composer hidden&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://kdab.github.io/cxx-qt/book/&quot;&gt;CXX-Qt&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 Nix compatibility&lt;/td&gt;&lt;td&gt;Qt&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/dioxus/latest/dioxus/&quot;&gt;Dioxus&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;WebView&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/dominator/latest/dominator/&quot;&gt;dominator&lt;/a&gt;&lt;/td&gt;&lt;td&gt;web only&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/egui/latest/egui/&quot;&gt;egui&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;🟡 CJK font setup&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/floem/latest/floem/&quot;&gt;floem&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/fltk&quot;&gt;FLTK&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;FLTK (bundled)&lt;/td&gt;&lt;td&gt;✅ OK (with extra setup)&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/flutter_rust_bridge/latest/flutter_rust_bridge/&quot;&gt;Flutter Rust Bridge&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;Flutter&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/freya/latest/freya/&quot;&gt;Freya&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://github.com/marek-g/rust-fui/blob/master/doc/SUMMARY.md&quot;&gt;Fui&lt;/a&gt;&lt;/td&gt;&lt;td&gt;no macOS support&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/gemgui/latest/gemgui/&quot;&gt;gemgui&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;Python &amp;amp; pywebview&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://www.gpui.rs/&quot;&gt;GPUI&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 no text input widget&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ I don’t know how to get it work&lt;/td&gt;&lt;td&gt;🟡 crash&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://longbridge.github.io/gpui-component/&quot;&gt;GPUI Component&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://gtk-rs.org/gtk3-rs/stable/latest/docs/gtk/&quot;&gt;GTK 3&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 use specific commit&lt;/td&gt;&lt;td&gt;GTK3&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4&quot;&gt;GTK 4&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;GTK4&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/iced/latest/iced/&quot;&gt;iced&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/imgui&quot;&gt;imgui&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 boilerplate&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/kas/&quot;&gt;KAS&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 API friction&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/kittest/latest/kittest/&quot;&gt;kittest&lt;/a&gt;&lt;/td&gt;&lt;td&gt;not a GUI framework&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/leptos/latest/leptos/&quot;&gt;Leptos&lt;/a&gt;&lt;/td&gt;&lt;td&gt;web only&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/lvgl/latest/lvgl/&quot;&gt;lvgl&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 embedded only&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://github.com/makepad/makepad&quot;&gt;Makepad&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 poor documentation&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;🟡 composer hidden&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/masonry/latest/masonry/&quot;&gt;masonry&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 low-level&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://crates.io/crates/maycoon&quot;&gt;Maycoon&lt;/a&gt;&lt;/td&gt;&lt;td&gt;deprecated&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/pane_ui&quot;&gt;Pane UI&lt;/a&gt;&lt;/td&gt;&lt;td&gt;😭 cannot load images&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://www.pax.dev&quot;&gt;Pax&lt;/a&gt;&lt;/td&gt;&lt;td&gt;😭 failed to compile&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://plyx.iz.rs/docs/getting-started/&quot;&gt;ply&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 odd default values&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;✅ OK (with extra setup)&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/qmetaobject/latest/qmetaobject/&quot;&gt;QMetaObject&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 Nix compatibility&lt;/td&gt;&lt;td&gt;Qt&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/relm/&quot;&gt;Relm&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;GTK3&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/relm4/&quot;&gt;Relm4&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;GTK4&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://ribir.org/docs/introduction&quot;&gt;Ribir&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 cryptic macros&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://cunarist.github.io/rinf/&quot;&gt;rinf&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;Flutter&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/rosin/latest/rosin/&quot;&gt;rosin&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 poor widgets library&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;✅ OK (with extra setup)&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/rui/latest/rui/&quot;&gt;rui&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 poor widgets library&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/sdl3/latest/sdl3/&quot;&gt;SDL3&lt;/a&gt;&lt;/td&gt;&lt;td&gt;not a GUI framework&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://slint.dev/docs&quot;&gt;slint&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://tauri.app/&quot;&gt;Tauri&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;WebView&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/tessera-ui/latest/tessera_ui/&quot;&gt;Tessera&lt;/a&gt;&lt;/td&gt;&lt;td&gt;no macOS support&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/tinyfiledialogs/latest/tinyfiledialogs/&quot;&gt;tinyfiledialogs&lt;/a&gt;&lt;/td&gt;&lt;td&gt;not a GUI framework&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/tk/latest/tk/&quot;&gt;Tk&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 API friction&lt;/td&gt;&lt;td&gt;Tcl/Tk&lt;/td&gt;&lt;td&gt;❌ No&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/undoredo&quot;&gt;undoredo&lt;/a&gt;&lt;/td&gt;&lt;td&gt;not a GUI framework&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.vizia.dev/vizia/&quot;&gt;Vizia&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 poor widgets library&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;❌ crash&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/webrender/latest/webrender/&quot;&gt;WebRender&lt;/a&gt;&lt;/td&gt;&lt;td&gt;not a GUI framework&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://microsoft.github.io/windows-docs-rs/&quot;&gt;Windows&lt;/a&gt;&lt;/td&gt;&lt;td&gt;😭 low-level API&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://github.com/microsoft/windows-rs/tree/master/crates/libs/reactor&quot;&gt;Windows Reactor&lt;/a&gt;&lt;/td&gt;&lt;td&gt;🟡 API friction&lt;/td&gt;&lt;td&gt;Windows App SDK (bundled)&lt;/td&gt;&lt;td&gt;🟡 text boxes only&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/winsafe/latest/winsafe/&quot;&gt;WinSafe&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;Windows only&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/wxdragon/latest/wxdragon/&quot;&gt;WxDragon&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;wxWidgets (bundled)&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/xilem/latest/xilem/&quot;&gt;Xilem&lt;/a&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;✅ OK&lt;/td&gt;&lt;td&gt;🟡 CJK fonts unsupported&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://docs.rs/yew/&quot;&gt;Yew&lt;/a&gt;&lt;/td&gt;&lt;td&gt;web only&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/article&gt;</content>
  </entry>
  <entry>
    <title>Migrating My Site to a Typst-Native Static Site Generator (a.k.a. a Preview of Aster)</title>
    <id>https://blog.wybxc.cc/blog/aster/</id>
    <link href="https://blog.wybxc.cc/blog/aster/"/>
    <published>2026-08-17T00:00:00Z</published>
    <updated>2026-08-17T00:00:00Z</updated>
    <content type="html" xml:base="https://blog.wybxc.cc/blog/aster/">&lt;article&gt;&lt;aside class&gt;&lt;p&gt;Aug 17, 2026&lt;br&gt;4 mins read&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;&lt;nav role=&quot;doc-toc&quot;&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/aster/#loc-1&quot;&gt;Migrating My Site to a Typst-Native Static Site Generator (a.k.a. a Preview of Aster)&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/nav&gt;&lt;/aside&gt;&lt;h2 id=&quot;loc-1&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/aster/#loc-1&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Migrating My Site to a Typst-Native Static Site Generator (a.k.a. a Preview of Aster)&lt;/h2&gt;&lt;p&gt;In early 2026, when I was preparing to rebuild my personal website, I wanted to find a static site generator that could: 1) use Typst to write content&lt;sup&gt;1&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;1.&lt;/span&gt;&lt;span&gt;MDX is actually comparable to Typst in expressiveness, but I prefer Typst’s math formula syntax.&lt;/span&gt;&lt;/span&gt;, and 2) be highly customizable and not rely on fixed templates. The only choice at that time was &lt;a href=&quot;https://astro.build&quot;&gt;Astro&lt;/a&gt;, with the &lt;a href=&quot;https://github.com/OverflowCat/astro-typst&quot;&gt;astro-typst&lt;/a&gt; plugin, which uses &lt;a href=&quot;https://github.com/Myriad-Dreamin/typst.ts&quot;&gt;typst.ts&lt;/a&gt; to compile Typst files to HTML.&lt;/p&gt;&lt;p&gt;This is a highly customizable solution, though part of the customization is done by hacking. To give Typst files the same flexibility as MDX, astro-typst uses a fixed pipeline: it first compiles Typst files to HTML, then applies an internal rehype plugin named &lt;code&gt;rehypeTransformJsxInTypst&lt;/code&gt; to handle MDX-style dynamic components in Typst. This is a reasonable default for an Astro integration, but it becomes troublesome if you want to customize it. For example, images inserted in Typst files are compiled to HTML with inline base64 data, which is not ideal for a website with many images. To extract images from the HTML, I had to use several rehype plugins&lt;sup&gt;2&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;2.&lt;/span&gt;&lt;span&gt;You can see the code at &lt;a href=&quot;https://github.com/Wybxc/wybxc.github.io/blob/b065cc83e59c115e78bf49a065a0c94c8c7db1d3/astro.config.mjs#L87&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt; to:&lt;/p&gt;&lt;ol&gt;&lt;li value=&quot;1&quot;&gt;Replace img tags containing base64 data with Astro’s Image component,&lt;/li&gt;&lt;li value=&quot;2&quot;&gt;Insert &lt;code&gt;import { Image } from &quot;astro:assets&quot;;&lt;/code&gt; at the beginning of the file, and&lt;/li&gt;&lt;li value=&quot;3&quot;&gt;Apply &lt;code&gt;rehypeTransformJsxInTypst&lt;/code&gt; again to handle the newly added dynamic components, because user-added rehype plugins run after astro-typst’s internal pipeline.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;There are also other issues, such as the incremental feature of the Typst compiler cannot be utilized in the pipeline, which causes a significant increase in build time, and in &lt;code&gt;npm dev&lt;/code&gt; mode, header size limitations of node.js can cause pictures to fail to load, etc. These issues are not insurmountable, but they are annoying and a waste of time.&lt;/p&gt;&lt;p&gt;That’s why I decided to create a Typst-native static site generator, which I named Aster&lt;sup&gt;3&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;3.&lt;/span&gt;&lt;span&gt;Obviously, it’s named after Astro.&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;The core idea of Aster is to use Typst as the language for content as well as for &lt;strong&gt;scripting&lt;/strong&gt;, and as the only language for scripting&lt;sup&gt;4&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;4.&lt;/span&gt;&lt;span&gt;Specifically, server-side scripting. In browser environments, JavaScript is still the only option.&lt;/span&gt;&lt;/span&gt;. Typst’s programming capability is powerful enough that it can mix scripting and markup in a way that is more intuitive than JSX and more flexible than MDX.&lt;/p&gt;&lt;p&gt;There have already been quite a few Typst-focused SSGs, such as &lt;a href=&quot;https://github.com/Myriad-Dreamin/shiroa&quot;&gt;Shiora&lt;/a&gt;, &lt;a href=&quot;https://github.com/Glomzzz/typsite&quot;&gt;Typsite&lt;/a&gt;, &lt;a href=&quot;https://typst.app/universe/package/tufted/&quot;&gt;Tufted&lt;/a&gt;, and &lt;a href=&quot;https://github.com/tola-rs/tola-ssg&quot;&gt;Tola&lt;/a&gt;. Most of them are closer to traditional SSGs like Jekyll or 11ty, where users choose one of the fixed templates and then write content in Typst. Tola’s philosophy is the most flexible one; it injects virtual packages such as &lt;code&gt;@tola/pages&lt;/code&gt; into the Typst environment, which contain information like how many pages the site has, the path and title of each page, etc. Users can use this information in Typst to generate pages. This allows Tola to achieve more flexible page generation than templates.&lt;/p&gt;&lt;p&gt;Aster draws on Astro’s design and takes inspiration from the working principles of Tola and &lt;a href=&quot;https://trunk-rs.github.io/trunk/&quot;&gt;Trunk&lt;/a&gt;. Specifically, Aster separates &lt;strong&gt;pages&lt;/strong&gt; and &lt;strong&gt;content&lt;/strong&gt;: pages follow file-based routing with an Astro-like dynamic routing mechanism, while content is referenced by pages to generate the actual page content. This separation mirrors Astro’s flexibility: the content side can focus purely on writing, while the page side focuses on styling and layout. In addition, Aster offers Trunk-style CSS and JS bundling, so you can write CSS and JS directly in Typst and have them automatically bundled into the site at build time.&lt;/p&gt;&lt;p&gt;Aster is written in Rust, which means it can call Typst’s Rust API directly. This allows it to take full advantage of the Typst compiler’s incremental compilation, significantly speeding up builds. For comparison, this site took over 10s to build with the previous architecture; with Aster, the first build takes only 2s, and subsequent incremental builds take just 0.6s.&lt;/p&gt;&lt;p&gt;Aster also includes a number of other features, such as:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;An Astro-like component system that lets you define components in Typst and use them in pages.&lt;/li&gt;&lt;li&gt;The ability to collect page information and generate arbitrary text files with Typst scripts, including sitemaps and RSS/Atom feeds.&lt;/li&gt;&lt;li&gt;Code block re-highlighting with &lt;a href=&quot;https://lumis.sh&quot;&gt;lumis&lt;/a&gt; to solve the problem of Typst’s built-in highlighting not adapting well to both dark and light modes.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I may have gotten a bit carried away. Although Aster is already available on &lt;a href=&quot;https://github.com/Wybxc/aster&quot;&gt;GitHub&lt;/a&gt; and &lt;a href=&quot;https://crates.io/crates/aster-ssg&quot;&gt;crates.io&lt;/a&gt;, I’m not quite ready to publish it yet. The interface between Aster and Typst files is still unstable, and I need more time to improve the documentation. Let this post be a preview of Aster for now.&lt;/p&gt;&lt;/article&gt;</content>
  </entry>
  <entry>
    <title>A New Design for Pretty Printer Implementations in Rust</title>
    <id>https://blog.wybxc.cc/blog/pretty-printer-pye/</id>
    <link href="https://blog.wybxc.cc/blog/pretty-printer-pye/"/>
    <published>2026-05-28T00:00:00Z</published>
    <updated>2026-05-28T00:00:00Z</updated>
    <content type="html" xml:base="https://blog.wybxc.cc/blog/pretty-printer-pye/">&lt;article&gt;&lt;aside class&gt;&lt;p&gt;May 28, 2026&lt;br&gt;6 mins read&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;&lt;nav role=&quot;doc-toc&quot;&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-pye/#loc-1&quot;&gt;A New Design for Pretty Printer Implementations in Rust&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/nav&gt;&lt;/aside&gt;&lt;h2 id=&quot;loc-1&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-pye/#loc-1&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;A New Design for Pretty Printer Implementations in Rust&lt;/h2&gt;&lt;p&gt;Since I studied &lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/&quot;&gt;Rustc’s pretty printer&lt;/a&gt; and implemented &lt;a href=&quot;https://crates.io/crates/elegance&quot;&gt;my own pretty printer library&lt;/a&gt; (which is used in the &lt;a href=&quot;https://crates.io/crates/cgrammar&quot;&gt;cgrammar&lt;/a&gt; crate, a crate for parsing and processing C23 syntax), I have been thinking about how to design a better pretty printer library, especially by applying the research results from academia &lt;sup&gt;1&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;1.&lt;/span&gt;&lt;span&gt;&lt;span role=&quot;doc-biblioref&quot;&gt;J. Hughes, “The Design of a Pretty-Printing Library,” in &lt;em&gt;Advanced Functional Programming&lt;/em&gt;, vol. 925, J. Jeuring, E. Meijer, G. Goos, J. Hartmanis, and J. Leeuwen, Eds., Berlin, Heidelberg: Springer Berlin Heidelberg, 1995, pp. 53–96. doi: &lt;a href=&quot;https://doi.org/10.1007/3-540-59451-5_3&quot; target=&quot;_blank&quot;&gt;10.1007/3-540-59451-5_3&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;sup&gt;2&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;2.&lt;/span&gt;&lt;span&gt;&lt;span role=&quot;doc-biblioref&quot;&gt;P. Wadler, “A Prettier Printer,” in &lt;em&gt;The Fun of Programming&lt;/em&gt;, J. Gibbons and O. De Moor, Eds., London: Macmillan Education UK, 2003, pp. 223–243. doi: &lt;a href=&quot;https://doi.org/10.1007/978-1-349-91518-7_11&quot; target=&quot;_blank&quot;&gt;10.1007/978-1-349-91518-7_11&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;sup&gt;3&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;3.&lt;/span&gt;&lt;span&gt;&lt;span role=&quot;doc-biblioref&quot;&gt;J.-P. Bernardy, “A Pretty but Not Greedy Printer (Functional Pearl),” &lt;em&gt;Proceedings of the ACM on Programming Languages&lt;/em&gt;, vol. 1, no. ICFP, pp. 1–21, Aug. 2017, doi: &lt;a href=&quot;https://doi.org/10.1145/3110250&quot; target=&quot;_blank&quot;&gt;10.1145/3110250&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; to practical Rust library designs.&lt;/p&gt;&lt;p&gt;An important obstacle is that academic research is often based on functional programming languages, and in particular assumes the existence of garbage collection, whereas Rust is a systems programming language without garbage collection. This means that memory management must be an extra consideration when implementing these designs in Rust.&lt;/p&gt;&lt;p&gt;For example, in a typical Wadler-style&lt;sup&gt;4&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;4.&lt;/span&gt;&lt;span&gt;For the differences between Wadler-style and Oppen-style pretty printers, see &lt;a href=&quot;https://docs.rs/elegance/0.4.0/elegance/#differences-from-other-libraries&quot;&gt;this explanation&lt;/a&gt; in the elegance crate’s documentation.&lt;/span&gt;&lt;/span&gt; pretty printer, the document structure is usually a recursive data type:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;ocaml&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;=&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Nil&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Append&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;of&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Group&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;of&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;FlatAlt&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;of&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Nest&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;of&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;int&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Hardline&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;of&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;string&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Union&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;of&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Fail&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This document structure is then converted into a string output through a layout function:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;ocaml&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;rec&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;d&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;width&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;string&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;(* implementation omitted *)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To implement such an algorithm in Rust, the most straightforward approach is to adopt the same pattern. For instance, the &lt;a href=&quot;https://crates.io/crates/pretty&quot;&gt;pretty&lt;/a&gt; crate implements Wadler’s classic algorithm (with some later supplements), and its document structure definition (simplified) is as follows:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;enum&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Nil&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Append&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;FlatAlt&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Nest&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;isize&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Hardline&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Union&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;Fail&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;BoxDoc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;BoxDoc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;RcDoc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Rc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;RcDoc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As shown above, the pretty crate makes the &lt;code&gt;Doc&lt;/code&gt; enum generic over a type &lt;code&gt;T&lt;/code&gt;, which can be either &lt;code&gt;BoxDoc&lt;/code&gt;, &lt;code&gt;RcDoc&lt;/code&gt;, or any other pointer type of &lt;code&gt;Doc&lt;/code&gt;. This allows users to make more flexible memory management decisions: using the lighter &lt;code&gt;BoxDoc&lt;/code&gt;, the more flexible but heavier &lt;code&gt;RcDoc&lt;/code&gt;, or some arena allocators. &lt;sup&gt;5&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;5.&lt;/span&gt;&lt;span&gt;Another benefit is that this design effectively turns &lt;code&gt;Doc&lt;/code&gt; from a type into a functor, enabling the use of functor-related abstractions (like catamorphisms) to implement efficient recursive algorithms; see the &lt;a href=&quot;https://crates.io/crates/recursion&quot;&gt;recursion&lt;/a&gt; crate.&lt;/span&gt;&lt;/span&gt; However, this design also has some limitations. For example, it forces all nodes in a document tree to use the same memory management strategy, which may lack flexibility in certain situations.&lt;/p&gt;&lt;p&gt;Oppen-style pretty printers (such as &lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/&quot;&gt;Rustc’s pretty printer&lt;/a&gt; and the &lt;a href=&quot;https://crates.io/crates/elegance&quot;&gt;elegance&lt;/a&gt; crate) do not have this problem because Oppen-style processes the document’s input and output as a stream without building a complete document tree. But the streaming approach of Oppen-style pretty printers also limits their expressive power. Research by Sorawee Porncharoenwase, et al. &lt;sup&gt;6&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;6.&lt;/span&gt;&lt;span&gt;&lt;span role=&quot;doc-biblioref&quot;&gt;S. Porncharoenwase, J. Pombrio, and E. Torlak, “A Pretty Expressive Printer,” &lt;em&gt;Proceedings of the ACM on Programming Languages&lt;/em&gt;, vol. 7, no. OOPSLA2, pp. 1122–1149, Oct. 2023, doi: &lt;a href=&quot;https://doi.org/10.1145/3622837&quot; target=&quot;_blank&quot;&gt;10.1145/3622837&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; points out that the general pretty printing problem is a global optimization problem; streaming pretty printers can only obtain a locally optimal solution through greedy algorithms and cannot guarantee global optimality. Therefore, to achieve a globally optimal pretty printer, one must build the complete document tree.&lt;/p&gt;&lt;p&gt;This post will propose a new design for pretty printer implementations in Rust, aiming to retain the expressive power of Wadler-style document trees while implementing them in a way that better aligns with Rust’s memory management.&lt;/p&gt;&lt;p&gt;The inspiration for this implementation comes from a concept in functional programming: a data type can be equivalently represented by the ways you consume it.&lt;sup&gt;7&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;7.&lt;/span&gt;&lt;span&gt;See my other blog post &lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/&quot;&gt;Church Encoding, Parametricity, and the Yoneda Lemma&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt; We are not really interested in the concrete structure of the document tree, but rather in how to use it to produce output.&lt;/p&gt;&lt;p&gt;Therefore, instead of defining a recursive data structure for &lt;code&gt;Doc&lt;/code&gt;, we can define &lt;code&gt;Doc&lt;/code&gt; as a trait, with a method that consumes the document and produces the output.&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;trait&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Render&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;RenderOutput&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The various document constructions then become different types implementing this trait, for example:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s2&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Clone&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Render&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;RenderOutput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Into&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Text&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And also:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s2&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;derive&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Clone&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Concat&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Concat&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Render&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;RenderOutput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;// fn Render::concat(&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;//     self: &amp;amp;Render,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;//     left: RenderOutput,&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;//     right: impl Fn(&amp;amp;Render) -&gt; RenderOutput&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;// ) -&gt; RenderOutput;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pub&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Concat&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;b&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this model, the structure of the document tree still exists. However, compared to the recursive data structure approach, it significantly reduces memory indirection and dynamic allocation overhead.&lt;/p&gt;&lt;p&gt;At the same time, it supports more flexible memory management. For example, you can mix &lt;code&gt;Box&amp;lt;dyn Doc&gt;&lt;/code&gt; and &lt;code&gt;Rc&amp;lt;dyn Doc&gt;&lt;/code&gt; within a document tree because both implement the &lt;code&gt;Doc&lt;/code&gt; trait.&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;dyn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Render&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;RenderOutput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Rc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;dyn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Doc&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Render&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;RenderOutput&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;renderer&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;From another perspective, this is somewhat similar to how we implement enumeration types in object-oriented languages (like C++): we define a base class for all documents, and each document construction is a subclass of this base class.&lt;/p&gt;&lt;p&gt;I wrote a proof-of-concept (referred to below as pye)&lt;sup&gt;8&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;8.&lt;/span&gt;&lt;span&gt;With assistance from AI. I did not publish the code for pye because I have not yet fully reviewed and structured it.&lt;/span&gt;&lt;/span&gt; for the above design, implementing the algorithm &lt;math&gt;&lt;msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;Π&lt;/mi&gt;&lt;mi&gt;𝑒&lt;/mi&gt;&lt;/msub&gt;&lt;/math&gt; from the paper &lt;em&gt;A pretty expressive printer&lt;/em&gt; (OOPSLA’23) &lt;sup&gt;9&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;9.&lt;/span&gt;&lt;span&gt;&lt;span role=&quot;doc-biblioref&quot;&gt;S. Porncharoenwase, J. Pombrio, and E. Torlak, “A Pretty Expressive Printer,” &lt;em&gt;Proceedings of the ACM on Programming Languages&lt;/em&gt;, vol. 7, no. OOPSLA2, pp. 1122–1149, Oct. 2023, doi: &lt;a href=&quot;https://doi.org/10.1145/3622837&quot; target=&quot;_blank&quot;&gt;10.1145/3622837&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, a general and globally optimal pretty printing algorithm, and conducted a performance comparison with the following crates:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The &lt;a href=&quot;https://crates.io/crates/pretty&quot;&gt;pretty&lt;/a&gt; crate, the most widely used Wadler-style pretty printer implementation in the Rust ecosystem.&lt;/li&gt;&lt;li&gt;The &lt;a href=&quot;https://crates.io/crates/elegance&quot;&gt;elegance&lt;/a&gt; crate, an Oppen-style streaming pretty printer implementation.&lt;/li&gt;&lt;li&gt;The &lt;a href=&quot;https://crates.io/crates/pretty-expressive&quot;&gt;pretty-expressive&lt;/a&gt; crate (referred to below as pe), a direct Rust implementation of the &lt;em&gt;A pretty expressive printer&lt;/em&gt; paper.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;On a 78kB JSON formatting task, pye achieved a 60x speedup over pe and reached about 57% of the performance of the pretty crate. The reason pye is slower than the pretty crate is mainly that pye implements a globally optimal algorithm, while the pretty crate uses a simpler greedy algorithm. However, compared to pe, which uses the same algorithm, pye’s performance improvement demonstrates that this new design is competitive in Rust.&lt;/p&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/ac8bddd9ea3a27f8.svg&quot; width=&quot;576&quot; height=&quot;336&quot; style=&quot;display: block&quot;&gt;&lt;p&gt;Below is a performance comparison on more formatting tasks, including JSON records, JSON arrays, deeply nested JSON, mixed JSON, and Lisp code. Each task has several variants: wide (ample line width to fit in one line), middle (moderate line width, like common use cases), and narrow (very small line width). On these tasks, pye’s performance is generally on par with pretty and elegance, and even surpasses both crates on some tasks, while significantly outperforming pe on the vast majority of tasks.&lt;/p&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/54270c7349901dfd.svg&quot; width=&quot;1536&quot; height=&quot;528&quot; style=&quot;display: block&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Updated:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;I added new experiments with more performance comparisons, including:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;An implementation using the design proposed in this post, but implementing the same greedy algorithm as the pretty crate (referred to below as pretty2);&lt;/li&gt;&lt;li&gt;The pretty crate, but using an arena allocator (referred to below as p-arena).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The experimental results are shown below:&lt;/p&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/f5a17a0d29b546a2.svg&quot; width=&quot;1536&quot; height=&quot;528&quot; style=&quot;display: block&quot;&gt;&lt;/div&gt;&lt;p&gt;Several more interesting findings can be observed:&lt;/p&gt;&lt;ol&gt;&lt;li value=&quot;1&quot;&gt;p-arena outperforms pretty, confirming that memory management is indeed a performance bottleneck in pretty printer implementations.&lt;/li&gt;&lt;li value=&quot;2&quot;&gt;pretty2 is faster than all other implementations, and on some tasks it achieves more than a 10x gap over pretty and p-arena (comparable to the performance gap between pye and pe) demonstrating that the design proposed in this post can indeed deliver significant performance improvements.&lt;/li&gt;&lt;li value=&quot;3&quot;&gt;pye is consistently slower than pretty2. This shows that while the proposed design can improve performance, the choice of algorithm (globally optimal vs. greedy) has an even greater impact on performance.&lt;/li&gt;&lt;li value=&quot;4&quot;&gt;The streaming-based elegance shows no performance advantage over pretty2 and p-arena. This may be due to the benchmark design: non-streaming algorithms only measure the time spent on the layout task, excluding document tree construction; whereas in streaming algorithms the two are interleaved, so both are included in the measured time.&lt;/li&gt;&lt;/ol&gt;&lt;section role=&quot;doc-bibliography&quot;&gt;&lt;ul style=&quot;list-style-type: none&quot;&gt;&lt;li id=&quot;loc-2&quot;&gt;J. Hughes, “The Design of a Pretty-Printing Library,” in &lt;em&gt;Advanced Functional Programming&lt;/em&gt;, vol. 925, J. Jeuring, E. Meijer, G. Goos, J. Hartmanis, and J. Leeuwen, Eds., Berlin, Heidelberg: Springer Berlin Heidelberg, 1995, pp. 53–96. doi: &lt;a href=&quot;https://doi.org/10.1007/3-540-59451-5_3&quot;&gt;10.1007/3-540-59451-5_3&lt;/a&gt;.&lt;/li&gt;&lt;li id=&quot;loc-3&quot;&gt;P. Wadler, “A Prettier Printer,” in &lt;em&gt;The Fun of Programming&lt;/em&gt;, J. Gibbons and O. De Moor, Eds., London: Macmillan Education UK, 2003, pp. 223–243. doi: &lt;a href=&quot;https://doi.org/10.1007/978-1-349-91518-7_11&quot;&gt;10.1007/978-1-349-91518-7_11&lt;/a&gt;.&lt;/li&gt;&lt;li id=&quot;loc-4&quot;&gt;J.-P. Bernardy, “A Pretty but Not Greedy Printer (Functional Pearl),” &lt;em&gt;Proceedings of the ACM on Programming Languages&lt;/em&gt;, vol. 1, no. ICFP, pp. 1–21, Aug. 2017, doi: &lt;a href=&quot;https://doi.org/10.1145/3110250&quot;&gt;10.1145/3110250&lt;/a&gt;.&lt;/li&gt;&lt;li id=&quot;loc-5&quot;&gt;S. Porncharoenwase, J. Pombrio, and E. Torlak, “A Pretty Expressive Printer,” &lt;em&gt;Proceedings of the ACM on Programming Languages&lt;/em&gt;, vol. 7, no. OOPSLA2, pp. 1122–1149, Oct. 2023, doi: &lt;a href=&quot;https://doi.org/10.1145/3622837&quot;&gt;10.1145/3622837&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/section&gt;&lt;/article&gt;</content>
  </entry>
  <entry>
    <title>Church Encoding, Parametricity, and the Yoneda Lemma</title>
    <id>https://blog.wybxc.cc/blog/parametricity/</id>
    <link href="https://blog.wybxc.cc/blog/parametricity/"/>
    <published>2026-05-19T00:00:00Z</published>
    <updated>2026-05-19T00:00:00Z</updated>
    <content type="html" xml:base="https://blog.wybxc.cc/blog/parametricity/">&lt;article&gt;&lt;aside class&gt;&lt;p&gt;May 19, 2026&lt;br&gt;20 mins read&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;&lt;nav role=&quot;doc-toc&quot;&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;div&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-1&quot;&gt;Church Encoding, Parametricity, and the Yoneda Lemma&lt;/a&gt;&lt;/div&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-2&quot;&gt;System F&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-3&quot;&gt;Parametricity&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-4&quot;&gt;Algebraic Data Types and Functors&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-5&quot;&gt;F-Algebra&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-6&quot;&gt;Initial Algebra&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-7&quot;&gt;The Yoneda Lemma&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-8&quot;&gt;The Final Recap&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/nav&gt;&lt;/aside&gt;&lt;h2 id=&quot;loc-1&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-1&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Church Encoding, Parametricity, and the Yoneda Lemma&lt;/h2&gt;&lt;p&gt;I still remember the shock I felt when I first encountered functional programming years ago. That was the moment I learned that natural numbers can be built within the language itself:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;hs&quot;&gt;&lt;span&gt;data Nat = Zero | Succ Nat&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I went on to learn that all computation can be expressed through functions (the lambda calculus), that recursion itself can be encoded as the mind-bending Y combinator:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;Y = λf. (λx. f (x x)) (λx. f (x x))&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And then there were Church numerals, where each number becomes a function:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;0 = λs. λz. z
1 = λs. λz. s z
2 = λs. λz. s (s z)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Church encoding represents natural numbers as functions; each number &lt;math&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;/math&gt; takes a successor function and a starting point, then applies the successor &lt;math&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;/math&gt; times.&lt;/p&gt;&lt;p&gt;But what is the reasoning behind it? Why these particular lambda terms?&lt;/p&gt;&lt;p&gt;There is also Church encoding for lists:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;nil  = λc. λn. n
cons = λx. λxs. λc. λn. c x (xs c n)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The pattern feels similar, but the details are different. For a long time I assumed this was just how things were: a clever trick, rediscovered case by case.&lt;/p&gt;&lt;p&gt;It is after many years of learning that I finally understand the deeper story. Church encoding manifests deep connections between data types, polymorphism, and category theory. Once you see the connections, the encoding’s shape stops being a trick and starts being inevitable.&lt;/p&gt;&lt;p&gt;I want to trace those connections here. We’ll start with the simplest data types, watch a pattern emerge, and build up the machinery: parametricity, algebraic data types, F-algebras, the Yoneda Lemma, until Church encoding looks less like a clever trick and more like something the math demands.&lt;/p&gt;&lt;h3 id=&quot;loc-2&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-2&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;System F&lt;/h3&gt;&lt;p&gt;To capture the pattern behind Church encoding, we need types. The untyped lambda calculus gives us the terms, but it gives us no vocabulary to say &lt;em&gt;what&lt;/em&gt; those terms are. That’s the Simply Typed Lambda Calculus (STLC), where every term has a type. The only type constructor in bare STLC is the function arrow &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;1.&lt;/span&gt;&lt;span&gt;To be precise, STLC also includes some base types, like &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; or &lt;math&gt;&lt;mtext&gt;𝙸𝚗𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;;&lt;/mo&gt;&lt;/math&gt; otherwise you cannot give the parameter of the innermost function a type. But the particular choice of base types is irrelevant to the story; we just need something in the language to talk about.&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;But STLC hits a wall almost immediately. A Church numeral must accept &lt;strong&gt;any&lt;/strong&gt; type as its carrier: the whole point is that &lt;math&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/math&gt; works the same whether you’re counting apples or functions. STLC can’t say that. Every function in STLC has a fixed, monomorphic type.&lt;/p&gt;&lt;p&gt;This is where the experienced programmer sits up: we need &lt;strong&gt;generics&lt;/strong&gt;. We need functions that are polymorphic over types. The calculus that gives us this is &lt;strong&gt;System F&lt;/strong&gt;, the polymorphic lambda calculus.&lt;/p&gt;&lt;p&gt;In System F, a function can take a type as an argument. You write type abstraction as &lt;math&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;Λ&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑡&lt;/mi&gt;&lt;/math&gt; and type application as &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Types of System F include type variables &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; function types &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and universal quantification &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;2.&lt;/span&gt;&lt;span&gt;Unlike STLC, base types are not necessary in System F. The polymorphism alone gives us enough structure to build everything we need.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Our System F starts as an empty universe. In STLC, we would declare base types like &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;/math&gt; to get started. But in System F, it’s interesting that we can build these types from scratch, using only functions and polymorphism. We can encode &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;/math&gt; as polymorphic functions, without any special syntax for data types.&lt;/p&gt;&lt;p&gt;Let me state a principle: a data type can be equivalently represented by the ways you consume it. I can’t yet explain the logic behind this claim, but let’s set it aside and see how it works for &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; &lt;sup&gt;3&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;3.&lt;/span&gt;&lt;span&gt;In the second half of this article, we’ll see the category-theoretic foundation for this principle. The Yoneda Lemma will show that the set of all ways to consume a type fully determines the type itself.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;If you’re holding a value of type &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; what can you do with it? The only way to consume a &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt; value is to ignore it and return something that has nothing to do with it.&lt;/p&gt;&lt;p&gt;Suppose you want to write a universal consumer: for any target type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; it turns a &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt; into an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Because we know nothing about &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; we cannot make up any new value of type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; The only thing we can do is to return an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; that we already have. But where do we get an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; from? We don’t have one! We should receive it as an argument. Therefore, the type signature of a universal consumer of &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt; is:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;Read as: “for any type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; give me an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; and I’ll give you back an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;”&lt;/p&gt;&lt;p&gt;What inhabits this type? It is easy to think of one: the identity function.&lt;sup&gt;4&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;4.&lt;/span&gt;&lt;span&gt;Later we’ll see that this is the only possible implementation, as a consequence of parametricity.&lt;/span&gt;&lt;/span&gt; It takes an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; and returns it unchanged:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;id = ΛX. λx. x&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This function is the Church encoding of &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Let’s try the same reasoning with &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;/math&gt; has two constructors, &lt;math&gt;&lt;mtext&gt;𝚃𝚛𝚞𝚎&lt;/mtext&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝙵𝚊𝚕𝚜𝚎&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;What does consuming a &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;/math&gt; require? You need a target type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and you need an interpretation for &lt;math&gt;&lt;mtext&gt;𝚃𝚛𝚞𝚎&lt;/mtext&gt;&lt;/math&gt; and one for &lt;math&gt;&lt;mtext&gt;𝙵𝚊𝚕𝚜𝚎&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; two values of type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Then, depending on which constructor the actual &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;/math&gt; value represents, you return the appropriate interpretation.&lt;/p&gt;&lt;p&gt;As a type signature:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;∀X. X → X → X&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Read as: “for any type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; give me two &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt;s and I’ll give you back an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;”&lt;/p&gt;&lt;p&gt;We can find two inhabitants of this type, which correspond to the two ways to consume a &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mo form=&quot;infix&quot; lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0em&quot;&gt;:&lt;/mo&gt;&lt;/math&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;true  = ΛX. λx. λy. x
false = ΛX. λx. λy. y&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;One chooses the first argument, the other chooses the second. They correspond exactly to the two values of &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Looking at these two examples, a pattern emerges:&lt;/p&gt;&lt;p&gt;The Church encoding of a data type in System F is a polymorphic function whose arguments match the constructors. It is a universal consumption interface for the type. This works perfectly for &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; whose constructors carry no data. But what about a type like the &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;/math&gt;? Its &lt;math&gt;&lt;mtext&gt;𝚂𝚞𝚌𝚌&lt;/mtext&gt;&lt;/math&gt; constructor has a recursive parameter. We’ll handle recursion soon. But before we do, we need to understand the mechanism that makes the pattern work in the first place.&lt;/p&gt;&lt;h3 id=&quot;loc-3&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-3&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Parametricity&lt;/h3&gt;&lt;p&gt;What’s striking is that for &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; we can only find a single implementation, the identity function. Likewise, for &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; we can only find two implementations, &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt;. The type system of System F does not permit any other implementations.&lt;/p&gt;&lt;p&gt;Once you have convinced yourself of the fact, let’s move on.&lt;/p&gt;&lt;p&gt;To understand &lt;strong&gt;why&lt;/strong&gt; the type system restricts the inhabitants so precisely, we need to examine the mechanism behind System F’s polymorphism. The polymorphism in System F is &lt;strong&gt;parametric&lt;/strong&gt;: a polymorphic function gets a type argument, but it can’t inspect it. It can’t branch on “am I dealing with Int or Bool?” It must treat the type as a black box. That restriction turns out to be the source of enormous power.&lt;/p&gt;&lt;p&gt;John Reynolds proved the &lt;strong&gt;parametricity theorem&lt;/strong&gt; (also called the &lt;strong&gt;abstraction theorem&lt;/strong&gt;) in 1983. Here is a compact statement:&lt;/p&gt;&lt;blockquote&gt;Let &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; be a closed term of System F, where &lt;math&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; is a type expression. For any types &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; and any relation &lt;math&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo&gt;⊆&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; let &lt;math&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;⊆&lt;/mo&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; be the relational lifting defined recursively from the structure of &lt;math&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; then &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/blockquote&gt;&lt;p&gt;The formulation looks abstract, but the message is simple: a polymorphic function must “preserve” whatever relation you associate with the type parameter. It cannot detect the concrete structure of the type it’s instantiated with. A consequence is that you can derive equations the function must satisfy purely from its type signature, regardless of implementation. Philip Wadler later called these “theorems for free.”&lt;/p&gt;&lt;p&gt;We’ll start with a special case you can verify by hand.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Claim&lt;/strong&gt;: &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; has only the identity function, i.e., any &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; must satisfy &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/math&gt; for all &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Proof&lt;/strong&gt;: Take two arbitrary types &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and pick any relation &lt;math&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo&gt;⊆&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; between them. The theorem requires us to lift &lt;math&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;/math&gt; through the type expression &lt;math&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; The lifting works like this: two functions &lt;math&gt;&lt;msub&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;msub&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; are related by &lt;math&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; precisely when they map &lt;math&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;/math&gt;-related inputs to &lt;math&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;/math&gt;-related outputs, that is, &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑦&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;/math&gt; whenever &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑦&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Intuitively, &lt;math&gt;&lt;msub&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;/math&gt; and &lt;math&gt;&lt;msub&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;/math&gt; preserve &lt;math&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;/math&gt; in lockstep.&lt;/p&gt;&lt;p&gt;Now, parametricity says: because &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/math&gt; is polymorphic, its instantiations at &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; must be related by this lifted relation. In symbols: &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝜏&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Spelling that out: for any &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑦&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; we have &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑦&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Here comes the trick. Fix a type &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; and a value &lt;math&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; We want to show &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Define a very specific relation that pairs &lt;math&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/math&gt; with itself and nothing else:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;{&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;}&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;⊆&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;Take &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Since &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; parametricity forces:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;But &lt;math&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;/math&gt; contains exactly one pair: &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; So &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/math&gt; must be &lt;math&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Done.&lt;/p&gt;&lt;p&gt;Parametricity forced &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/math&gt; to be the identity function. &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/math&gt; knows nothing about the type it’s applied to; the type signature alone left it no other choice.&lt;/p&gt;&lt;p&gt;A similar argument works for &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; A function of this type receives two values of an unknown type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; and must return an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; With no operations available on &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; the only possible behaviors are “always return the first argument” or “always return the second.” That’s &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt;.&lt;sup&gt;5&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;5.&lt;/span&gt;&lt;span&gt;A formal proof follows the same relational strategy, using &lt;math&gt;&lt;mi&gt;𝑅&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;{&lt;/mo&gt;&lt;mrow&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑏&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑏&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;mo&gt;}&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; for two distinct values &lt;math&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑏&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Now let’s look at the general shape &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt;. Here &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; is any type operator; think of it as describing the structure of a data type. The free theorem we get is this: for any F-algebra homomorphism&lt;sup&gt;6&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;6.&lt;/span&gt;&lt;span&gt;We’ll explain what an F-algebra homomorphism is later.&lt;/span&gt;&lt;/span&gt; &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt;&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;/math&gt;&lt;p&gt;This equation will play a central role later when we prove that Church encoding is equivalent to the data type it encodes.&lt;/p&gt;&lt;h3 id=&quot;loc-4&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-4&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Algebraic Data Types and Functors&lt;/h3&gt;&lt;p&gt;With parametricity in our toolkit, we now return to the main thread. Recall where we left off: &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;/math&gt; revealed a pattern (Church encoding is a polymorphic function whose arguments match the constructors), but we had no way to handle recursive types like &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; To extend the pattern, we need a systematic language for describing the structure of data types — something that makes constructors and their arguments explicit. This is where &lt;strong&gt;algebraic data types&lt;/strong&gt; (ADT) come in.&lt;/p&gt;&lt;p&gt;We know that tuples are &lt;strong&gt;product types&lt;/strong&gt; and tagged unions are &lt;strong&gt;sum types&lt;/strong&gt;. An algebraic data type is built from these two operations, fundamentally, as a &lt;strong&gt;sum of products&lt;/strong&gt;. Each constructor is a product of its fields; the whole type is the sum among constructors. If a constructor carries no data, it is the empty product, i.e., the &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt; type.&lt;/p&gt;&lt;p&gt;We can make this precise with a small algebraic notation:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;math&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/math&gt; (the unit type, &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt;): a type with exactly one value. It is the identity of the product: &lt;math&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/li&gt;&lt;li&gt;&lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; (the sum type): a value is either an &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; or a &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; tagged with the choice.&lt;/li&gt;&lt;li&gt;&lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; (the product type): a pair of an &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; and a &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Under this notation:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtable class=&quot;multiline-equation aligned&quot;&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mo form=&quot;infix&quot;&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mo form=&quot;infix&quot;&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mo form=&quot;infix&quot;&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;/mtable&gt;&lt;/math&gt;&lt;p&gt;The last line reads: a natural number is either &lt;math&gt;&lt;mtext&gt;𝚉𝚎𝚛𝚘&lt;/mtext&gt;&lt;/math&gt; (the &lt;math&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/math&gt; branch, carrying no information) or &lt;math&gt;&lt;mtext&gt;𝚂𝚞𝚌𝚌&lt;/mtext&gt;&lt;/math&gt; (wrapping another &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;/math&gt;). The equation is recursive, and we make sense of it with the &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;/math&gt; binder:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;The same recipe works for lists:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtext&gt;𝙻𝚒𝚜𝚝&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;Here, &lt;math&gt;&lt;mtext&gt;𝙽𝚒𝚕&lt;/mtext&gt;&lt;/math&gt; is the &lt;math&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/math&gt; branch and &lt;math&gt;&lt;mtext&gt;𝙲𝚘𝚗𝚜&lt;/mtext&gt;&lt;/math&gt; is the &lt;math&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; branch.&lt;/p&gt;&lt;p&gt;But the algebra goes deeper than notation. Types surprisingly obey the familiar laws of algebra. For example, the distributivity law:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑏&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝑏&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;Here &lt;math&gt;&lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;≅&lt;/mo&gt;&lt;/math&gt; denotes type isomorphism: there exist functions witnessing the equivalence in both directions.&lt;/p&gt;&lt;p&gt;Read the law as types: &lt;code&gt;(a, Either b c)&lt;/code&gt; is isomorphic to &lt;code&gt;Either (a, b) (a, c)&lt;/code&gt;. As evidence, we can write the following functions:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;hs&quot;&gt;&lt;span&gt;f :: (a, Either b c) -&gt; Either (a, b) (a, c)
f (a, Left b)  = Left  (a, b)
f (a, Right c) = Right (a, c)

g :: Either (a, b) (a, c) -&gt; (a, Either b c)
g (Left (a, b))  = (a, Left b)
g (Right (a, c)) = (a, Right c)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;What about function types? Can we express them in terms of algebraic operations?&lt;/p&gt;&lt;p&gt;Let me declare: &lt;strong&gt;functions are exponents.&lt;/strong&gt; Consider two finite types &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; with &lt;math&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;/math&gt; and &lt;math&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;/math&gt; inhabitants respectively. How many functions &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; exist? For each input &lt;math&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; we can independently choose any output &lt;math&gt;&lt;mi&gt;𝑏&lt;/mi&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; That’s &lt;math&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;/math&gt; choices repeated &lt;math&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;/math&gt; times: &lt;math&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;msup&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;|&lt;/mo&gt;&lt;/mrow&gt;&lt;/msup&gt;&lt;/math&gt; possibilities. This suggests writing the function type as an exponential:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msup&gt;&lt;/math&gt;&lt;p&gt;Currying then becomes the familiar exponent law:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;msup&gt;&lt;mi&gt;𝐶&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/mrow&gt;&lt;/msup&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;msup&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;𝐶&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msup&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msup&gt;&lt;/math&gt;&lt;p&gt;And functions out of sums follow their own distributive law:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;msup&gt;&lt;mi&gt;𝐶&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;+&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/mrow&gt;&lt;/msup&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;𝐶&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msup&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;𝐶&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msup&gt;&lt;/math&gt;&lt;p&gt;Now let’s return to the Church encoding of natural numbers. We have seen Church numerals in untyped lambda calculus:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;0 = λs. λz. z
1 = λs. λz. s z
2 = λs. λz. s (s z)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We want to give them types in System F. Assume the type of &lt;code&gt;z&lt;/code&gt; is &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; We expect the type of &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt; to be the same, so term &lt;code&gt;s z&lt;/code&gt; should have the same type as &lt;code&gt;z&lt;/code&gt;. Therefore, &lt;code&gt;s&lt;/code&gt; must have type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; That gives us the Church encoding type for natural numbers:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtext&gt;ChurchNat&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;It looks somewhat different from the Church encoding types for &lt;code&gt;Unit&lt;/code&gt; and &lt;code&gt;Bool&lt;/code&gt;. The second argument is a function rather than a value. Is there a single shape that captures all of them?&lt;/p&gt;&lt;p&gt;Let’s inspect the inner part of the encoding more closely.&lt;/p&gt;&lt;p&gt;Currying tells us that a function &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; is equivalent to a function &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; And we already know that the tuple &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; can be written as &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and the function type &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; can be written as &lt;math&gt;&lt;msup&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msup&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Then we can do some algebraic manipulation:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtable class=&quot;multiline-equation aligned&quot;&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mo lspace=&quot;0em&quot;&gt;≅&lt;/mo&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/msup&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mo lspace=&quot;0em&quot;&gt;≅&lt;/mo&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;msup&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;/msup&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mo lspace=&quot;0em&quot;&gt;≅&lt;/mo&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;/mtable&gt;&lt;/math&gt;&lt;p&gt;So the full Church encoding becomes:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtext&gt;ChurchNat&lt;/mtext&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;Look at the expression &lt;math&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; That is precisely the body of the recursive type definition of &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; In other words, the Church encoding is of the form:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mspace width=&quot;1em&quot;/&gt;&lt;mtext&gt;where&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;Here, &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; is a &lt;strong&gt;functor&lt;/strong&gt; that captures the shape of the algebraic data type. Let’s check that this holds for our earlier examples:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;For &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mo form=&quot;infix&quot; lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0em&quot;&gt;:&lt;/mo&gt;&lt;/math&gt; the functor is &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Then &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Matches &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/li&gt;&lt;li&gt;For &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mo form=&quot;infix&quot; lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0em&quot;&gt;:&lt;/mo&gt;&lt;/math&gt; the functor is &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Then &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;×&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Matches &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Here we get the general pattern: for an algebraic data type &lt;math&gt;&lt;mi&gt;𝑇&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; its Church encoding is &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;In the next section, we’ll see that &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; is the type of universal consumers of &lt;strong&gt;F-algebras&lt;/strong&gt;, and this is the perspective that will lead us, via parametricity and the Yoneda Lemma, to the deepest understanding of what Church encoding really is.&lt;/p&gt;&lt;h3 id=&quot;loc-5&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-5&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;F-Algebra&lt;/h3&gt;&lt;p&gt;We’ve arrived at a turning point. The last section ended with a shape, &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; that unifies the Church encodings of &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; But the shape still feels pulled from thin air. Why this particular arrangement of symbols? To answer that, we need to give names to the pieces. Category theory enters here.&lt;/p&gt;&lt;p&gt;A &lt;strong&gt;category&lt;/strong&gt; is a collection of objects and arrows between them, with sensible rules for &lt;em&gt;composition&lt;/em&gt; and &lt;em&gt;identity&lt;/em&gt;. For a programmer, the natural example is the category &lt;math&gt;&lt;mtext&gt;𝐒𝐞𝐭&lt;/mtext&gt;&lt;mo form=&quot;infix&quot; lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0em&quot;&gt;:&lt;/mo&gt;&lt;/math&gt; objects are types, arrows are functions, composition is function composition, and the identity arrow is &lt;code&gt;id&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;A &lt;strong&gt;functor&lt;/strong&gt; &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; is a mapping between categories. In our world, &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; maps each type &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; to a type &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and each function &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; to a function &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; preserving composition and identity:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtable class=&quot;multiline-equation aligned&quot;&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mo form=&quot;infix&quot;&gt;=&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;id&lt;/mtext&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mo form=&quot;infix&quot;&gt;=&lt;/mo&gt;&lt;mtext&gt;id&lt;/mtext&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;/mtable&gt;&lt;/math&gt;&lt;p&gt;This is what the &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; in &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; has been doing: it builds a new type from an old one, &lt;strong&gt;and&lt;/strong&gt; it lifts functions to act inside that structure.&lt;sup&gt;7&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;7.&lt;/span&gt;&lt;span&gt;For &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝𝙵&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; given &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑌&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝𝙵&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/math&gt; maps &lt;math&gt;&lt;mtext&gt;𝙻𝚎𝚏𝚝&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; to &lt;math&gt;&lt;mtext&gt;𝙻𝚎𝚏𝚝&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝚁𝚒𝚐𝚑𝚝&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;/math&gt; to &lt;math&gt;&lt;mtext&gt;𝚁𝚒𝚐𝚑𝚝&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; This function-lifting is the machinery behind structural recursion; we’ll return to it when we define folds.&lt;/p&gt;&lt;p&gt;A &lt;strong&gt;natural transformation&lt;/strong&gt; &lt;math&gt;&lt;mi&gt;𝜂&lt;/mi&gt;&lt;/math&gt; between two functors &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;𝐺&lt;/mi&gt;&lt;/math&gt; is a way of turning &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; shapes into &lt;math&gt;&lt;mi&gt;𝐺&lt;/mi&gt;&lt;/math&gt; shapes, uniformly for all types. For each type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; you have an arrow &lt;math&gt;&lt;msub&gt;&lt;mi&gt;𝜂&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/msub&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐺&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and for every function &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑌&lt;/mi&gt;&lt;/math&gt; the following square commutes:&lt;/p&gt;&lt;div class=&quot;typst-center&quot;&gt;&lt;span class=&quot;typst-invert&quot;&gt;&lt;svg style=&quot;overflow: visible; width: 9.532541963em; height: 8.443230852em;&quot; viewBox=&quot;0 0 104.857961592 92.87553937&quot; width=&quot;104.857961592pt&quot; height=&quot;92.87553937pt&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; xmlns:h5=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(38.612922222 16.434)&quot; d=&quot;M 0 0h 40.25009502&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(76.789559756 16.433999906)&quot; d=&quot;M 0 0m 2.073457535 0c -1.064538428 0.489632971 -1.833840644 1.455047916 -2.073457535 2.602029282&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(76.789559756 13.831970623)&quot; d=&quot;M 0 0m 2.073457535 2.602029282c -1.064538428 -0.489632971 -1.833840644 -1.455047916 -2.073457535 -2.602029282&quot;/&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(48.00624751)&quot; d=&quot;M 0 0h 21.727444444v 12.034h -21.727444444v -12.034Z &quot;/&gt;&lt;g transform=&quot;translate(48.006247465 -3.1e-8)&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 2.2 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g7CF395EBAD04303597139525CE722D4&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 13.191444444 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g6F013E8102D3CE54005BADBEC7660725&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(22.2827 26.190499906)&quot; d=&quot;M 0 0l 0 52.908039465&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(19.680670718 77.025081614)&quot; d=&quot;M 0 0m 2.602029282 2.073457535c -0.489632971 -1.064538428 -1.455047916 -1.833840644 -2.602029282 -2.073457535&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(22.2827 77.025081614)&quot; d=&quot;M 0 0m 0 2.073457535c 0.489632971 -1.064538428 1.455047916 -1.833840644 2.602029282 -2.073457535&quot;/&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(0 45.461519638)&quot; d=&quot;M 0 0h 17.8827v 14.63h -17.8827v -14.63Z &quot;/&gt;&lt;g transform=&quot;translate(-4.7e-8 45.461519622)&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 2.2 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g7F31FCDEC964522AB5C8F7519E8E9A3B&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 7.667 12.43)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g8D72C7566C2B07B1579AFD0B11491AF2&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(94.96773937 26.190499906)&quot; d=&quot;M 0 0v 52.908039465&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(92.365710182 77.025081614)&quot; d=&quot;M 0 0m 2.602029282 2.073457535c -0.489632971 -1.064538428 -1.455047916 -1.833840644 -2.602029282 -2.073457535&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(94.967739465 77.025081614)&quot; d=&quot;M 0 0m 0 2.073457535c 0.489632971 -1.064538428 1.455047916 -1.833840644 2.602029282 -2.073457535&quot;/&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(73.30103937 45.461519638)&quot; d=&quot;M 0 0h 17.2667v 14.63h -17.2667v -14.63Z &quot;/&gt;&lt;g transform=&quot;translate(73.301039307 45.461519622)&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 2.2 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g7F31FCDEC964522AB5C8F7519E8E9A3B&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 7.667 12.43)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g46611C892D9F4B6541828578CAE9403C&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(38.662422222 89.11903937)&quot; d=&quot;M 0 0h 40.15109502&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(76.740059756 89.11903937)&quot; d=&quot;M 0 0m 2.073457535 0c -1.064538428 0.489632971 -1.833840644 1.455047916 -2.073457535 2.602029282&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(76.740059756 86.517010088)&quot; d=&quot;M 0 0m 2.073457535 2.602029282c -1.064538428 -0.489632971 -1.833840644 -1.455047916 -2.073457535 -2.602029282&quot;/&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(47.95674751 72.56403937)&quot; d=&quot;M 0 0h 21.826444444v 12.155h -21.826444444v -12.155Z &quot;/&gt;&lt;g transform=&quot;translate(47.956747465 72.564039354)&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 2.2 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g803670B2CD55A41AE04C5455C9670B48&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 13.290444444 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g6F013E8102D3CE54005BADBEC7660725&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(11.952477778 12.6775)&quot; d=&quot;M 0 0h 20.660444445v 7.513h -20.660444445v -7.513Z &quot;/&gt;&lt;g transform=&quot;translate(11.952477748 12.677499921)&quot;&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 0 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g7CF395EBAD04303597139525CE722D4&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 10.991444444 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g481AE727E6F914D5199E83A214575C36&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(85.127017148 12.6775)&quot; d=&quot;M 0 0h 19.681444445v 7.513h -19.681444445v -7.513Z &quot;/&gt;&lt;g transform=&quot;translate(85.127017055 12.677499921)&quot;&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 0 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g7CF395EBAD04303597139525CE722D4&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 10.991444444 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g6F5992FA517D1182004B86DB427D458C&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(11.902977778 85.36253937)&quot; d=&quot;M 0 0h 20.759444445v 7.513h -20.759444445v -7.513Z &quot;/&gt;&lt;g transform=&quot;translate(11.902977748 85.362539291)&quot;&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 0 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g803670B2CD55A41AE04C5455C9670B48&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 11.090444444 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g481AE727E6F914D5199E83A214575C36&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(85.077517148 85.36253937)&quot; d=&quot;M 0 0h 19.780444445v 7.513h -19.780444445v -7.513Z &quot;/&gt;&lt;g transform=&quot;translate(85.077517055 85.362539291)&quot;&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 0 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g803670B2CD55A41AE04C5455C9670B48&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 11.090444444 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g6F5992FA517D1182004B86DB427D458C&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;defs&gt;&lt;symbol id=&quot;g7CF395EBAD04303597139525CE722D4&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 2.189 7.216c 0 -0.11 0.121 -0.165 0.352 -0.165c 0.44 0 0.66 -0.044 0.66 -0.143c 0 -0.033 -0.022 -0.11 -0.055 -0.253l -1.43 -5.753c -0.066 -0.242 -0.176 -0.385 -0.33 -0.44c -0.077 -0.022 -0.275 -0.033 -0.616 -0.033c -0.242 0 -0.352 -0.022 -0.352 -0.253c 0 -0.121 0.066 -0.176 0.209 -0.176l 1.43 0.033l 1.628 -0.033c 0.176 0 0.264 0.088 0.264 0.253c 0 0.187 -0.121 0.176 -0.407 0.176c -0.484 0 -0.759 0.022 -0.825 0.077c -0.033 0.011 -0.044 0.055 -0.044 0.11l 0.704 2.915h 1.023c 0.506 0 0.858 -0.022 0.858 -0.44c 0 -0.143 -0.022 -0.319 -0.077 -0.528c -0.011 -0.033 -0.022 -0.077 -0.033 -0.121c 0 -0.121 0.055 -0.176 0.176 -0.176c 0.055 0.011 0.132 0.088 0.209 0.253l 0.594 2.365c 0.022 0.088 0.033 0.154 0.033 0.187c -0.033 0.099 -0.099 0.154 -0.176 0.154c -0.088 0 -0.154 -0.088 -0.198 -0.253c -0.11 -0.418 -0.264 -0.682 -0.44 -0.814c -0.176 -0.132 -0.484 -0.198 -0.924 -0.198h -0.935l 0.682 2.706c 0.088 0.374 0.088 0.385 0.55 0.385h 1.43c 1.067 0 1.551 -0.165 1.551 -1.144c 0 -0.22 -0.011 -0.418 -0.033 -0.583c -0.011 -0.121 -0.022 -0.187 -0.022 -0.198c 0 -0.121 0.055 -0.176 0.165 -0.176c 0.11 0 0.176 0.099 0.198 0.308l 0.22 1.881c 0.033 0.308 -0.044 0.341 -0.341 0.341h -5.324c -0.253 0 -0.374 -0.011 -0.374 -0.264Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g6F013E8102D3CE54005BADBEC7660725&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 5.632 1.518c -0.253 -0.869 -0.605 -1.309 -1.067 -1.309c -0.143 0 -0.22 0.099 -0.22 0.308c 0 0.165 0.066 0.418 0.198 0.759c 0.44 1.177 0.66 1.98 0.66 2.409c 0 0.781 -0.506 1.21 -1.287 1.21c -0.583 0 -1.089 -0.242 -1.518 -0.715l 0.803 3.289c -0.022 0.099 -0.044 0.165 -0.187 0.165c -0.363 0 -1.166 -0.099 -1.309 -0.11c -0.165 -0.022 -0.253 -0.099 -0.253 -0.264c 0 -0.11 0.099 -0.165 0.297 -0.165c 0.231 0 0.484 0.011 0.506 -0.143l -1.606 -6.479c -0.033 -0.121 -0.044 -0.198 -0.044 -0.242c 0 -0.231 0.121 -0.352 0.352 -0.352c 0.22 0 0.374 0.11 0.451 0.319l 0.44 1.804c 0.132 0.539 0.231 0.946 0.308 1.221c 0.033 0.077 0.121 0.231 0.264 0.451c 0.396 0.594 0.88 0.891 1.463 0.891c 0.363 0 0.539 -0.242 0.539 -0.715c 0 -0.451 -0.22 -1.254 -0.66 -2.42c -0.099 -0.253 -0.143 -0.451 -0.143 -0.616c 0 -0.528 0.396 -0.935 0.924 -0.935c 0.484 0 0.869 0.275 1.144 0.836c 0.209 0.44 0.319 0.737 0.319 0.88c 0 0.099 -0.055 0.154 -0.176 0.154c -0.033 0 -0.198 -0.099 -0.198 -0.231Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g7F31FCDEC964522AB5C8F7519E8E9A3B&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 4.169 4.862c -0.671 0 -1.221 -0.297 -1.65 -0.88c -0.077 0.495 -0.462 0.88 -1.023 0.88c -0.451 0 -0.781 -0.363 -1.012 -1.078c -0.11 -0.363 -0.165 -0.572 -0.165 -0.638c 0 -0.099 0.055 -0.154 0.176 -0.154c 0.055 0 0.088 0.011 0.121 0.033c 0.055 0.099 0.088 0.176 0.099 0.253c 0.198 0.836 0.451 1.254 0.748 1.254c 0.198 0 0.297 -0.154 0.297 -0.451c 0 -0.143 -0.055 -0.451 -0.176 -0.902l -0.627 -2.508c -0.033 -0.143 -0.099 -0.429 -0.099 -0.484c 0 -0.22 0.121 -0.33 0.363 -0.33c 0.209 0 0.363 0.11 0.44 0.33c 0.011 0.055 0.077 0.33 0.198 0.803l 0.242 0.979c 0.132 0.539 0.231 0.946 0.308 1.221c 0.033 0.077 0.121 0.231 0.264 0.451c 0.396 0.594 0.88 0.891 1.463 0.891c 0.363 0 0.539 -0.242 0.539 -0.715c 0 -0.165 -0.033 -0.385 -0.11 -0.671l -1.232 -5.005c -0.022 -0.088 -0.033 -0.143 -0.033 -0.176c 0 -0.231 0.121 -0.341 0.352 -0.341c 0.242 0 0.407 0.154 0.484 0.473l 1.232 4.917c 0.055 0.231 0.088 0.451 0.088 0.638c 0 0.792 -0.495 1.21 -1.287 1.21Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g8D72C7566C2B07B1579AFD0B11491AF2&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 6.3294 5.2283c -0.1617 0 -0.7238 0.0308 -0.8855 0.0308c -0.1232 0 -0.1848 -0.0693 -0.1848 -0.2002c 0.0231 -0.077 0.0308 -0.1309 0.1463 -0.1309c 0.154 -0.0231 0.231 -0.077 0.231 -0.1617c 0 -0.077 -0.0616 -0.1771 -0.1848 -0.2926l -1.2782 -1.2551l -0.7546 1.4553c -0.0231 0.0385 -0.0385 0.0693 -0.0385 0.0924c 0.0539 0.1078 0.231 0.1617 0.3696 0.1617c 0.1309 0 0.2002 0.0693 0.2002 0.2002c -0.0231 0.077 -0.0385 0.1309 -0.1617 0.1309c -0.1001 0 -0.4158 -0.0231 -0.5082 -0.0231c -0.5005 -0.0077 -0.8162 -0.0077 -0.9471 0c -0.2618 0.0154 -0.4004 0.0231 -0.4158 0.0231c -0.1309 0 -0.1925 -0.0693 -0.1925 -0.2002c 0 -0.0847 0.0847 -0.1309 0.2541 -0.1309c 0.1386 0 0.2464 -0.0077 0.3234 -0.0308c 0.1386 -0.0462 0.1463 -0.0539 0.2079 -0.1848l 1.0549 -2.079l -1.0472 -1.0395c -0.5544 -0.5313 -0.924 -0.8701 -1.1165 -1.0087c -0.1309 -0.0924 -0.2772 -0.154 -0.4312 -0.1925c -0.0616 -0.0154 -0.2156 -0.0385 -0.4697 -0.0693c -0.077 -0.0077 -0.1155 -0.0693 -0.1155 -0.1848c 0 -0.0924 0.0462 -0.1386 0.1386 -0.1386c 0.1309 0 0.5775 0.0308 0.7084 0.0308c 0.3003 0 0.77 -0.0308 0.8855 -0.0308c 0.1309 0 0.1925 0.0616 0.1925 0.1925c 0 0.0924 -0.0539 0.1386 -0.1694 0.1386c -0.1386 0.0154 -0.2079 0.0693 -0.2079 0.1617c 0 0.077 0.0847 0.2002 0.2618 0.3696l 1.5169 1.4861l 0.9009 -1.771c 0.0231 -0.0385 0.0385 -0.0616 0.0462 -0.0847c -0.0539 -0.1001 -0.2156 -0.1463 -0.3773 -0.1617c -0.1309 -0.0077 -0.1925 -0.0693 -0.1925 -0.2002c 0.0231 -0.0847 0.0308 -0.1309 0.154 -0.1309c 0.0924 0 0.4235 0.0231 0.5159 0.0231c 0.5005 0.0077 0.8162 0.0077 0.9471 0c 0.2618 -0.0154 0.4004 -0.0231 0.4081 -0.0231c 0.1309 0 0.1925 0.0693 0.1925 0.2002c 0 0.0847 -0.0847 0.1309 -0.2541 0.1309c -0.2772 0 -0.4312 0.0231 -0.5159 0.2002l -1.2243 2.4024l 0.7084 0.7084c 0.5236 0.5159 0.9009 0.8624 1.1396 1.0241c 0.2849 0.2002 0.4389 0.2079 0.9086 0.2695c 0.077 0.0077 0.1155 0.0693 0.1155 0.1771c 0 0.1001 -0.0462 0.1463 -0.1386 0.1463c -0.1309 0 -0.5852 -0.0308 -0.7161 -0.0308Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g46611C892D9F4B6541828578CAE9403C&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 5.8135 5.2283c -0.1463 0 -0.6468 0.0308 -0.7931 0.0308c -0.1232 0 -0.1848 -0.0693 -0.1848 -0.2002c 0 -0.077 0.0616 -0.1232 0.1848 -0.1386c 0.1232 -0.0154 0.1771 -0.0539 0.1771 -0.1078c 0 -0.077 -0.077 -0.1925 -0.2233 -0.3465l -1.8711 -1.9558l -0.9933 2.1868c -0.0231 0.0539 -0.0385 0.1001 -0.0462 0.1232c 0 0.0693 0.1232 0.1078 0.3773 0.1078c 0.1617 0 0.231 0.0539 0.231 0.1925v 0.0308c -0.0231 0.0693 -0.0693 0.1078 -0.154 0.1078c -0.1925 0 -0.8239 -0.0308 -1.0164 -0.0308c -0.1617 0 -0.7084 0.0308 -0.8701 0.0308c -0.1232 0 -0.1848 -0.0693 -0.1848 -0.2002c 0 -0.0847 0.077 -0.1309 0.2387 -0.1309c 0.2541 0 0.4004 -0.0308 0.4466 -0.0847c 0.0231 -0.0308 0.0462 -0.077 0.0693 -0.1386l 1.1781 -2.5949l -0.3388 -1.3783c -0.0462 -0.1925 -0.1001 -0.3003 -0.154 -0.3388c -0.0539 -0.0385 -0.231 -0.0539 -0.5159 -0.0616h -0.1232c -0.0924 -0.0077 -0.1386 -0.0693 -0.1386 -0.1848c 0 -0.1001 0.0539 -0.1463 0.154 -0.1463c 0.308 0 0.6545 0.0385 0.9779 0.0308l 0.4851 -0.0077c 0.0847 0 0.4158 -0.0231 0.5082 -0.0231c 0.1309 0 0.2002 0.0693 0.2002 0.2002c 0 0.0847 -0.1001 0.1309 -0.2926 0.1309c -0.2541 0 -0.4235 -0.0154 -0.4235 0.0924c 0 0.0385 0.0462 0.2387 0.1463 0.6083c 0.1386 0.5621 0.2233 0.8778 0.231 0.9394c 0.0231 0.0847 0.0616 0.1463 0.1001 0.1925l 2.0328 2.1329c 0.3619 0.385 0.7469 0.5929 1.1396 0.6314c 0.1463 0.0077 0.2002 0.0539 0.2002 0.1925c 0 0.0924 -0.0462 0.1386 -0.1386 0.1386c -0.1078 0 -0.5082 -0.0308 -0.616 -0.0308Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g803670B2CD55A41AE04C5455C9670B48&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 3.564 -0.242c 0.968 0 1.727 0.297 2.288 0.891c 0.066 -0.143 0.352 -0.638 0.506 -0.638c 0.055 0 0.088 0.033 0.11 0.077c 0.022 0.044 0.099 0.264 0.198 0.66l 0.198 0.836c 0.066 0.253 0.11 0.44 0.143 0.561c 0.121 0.484 0.121 0.473 0.715 0.484c 0.143 0 0.209 0.088 0.209 0.264c 0 0.11 -0.055 0.165 -0.176 0.165c -0.209 0 -0.935 -0.044 -1.144 -0.033l -1.529 0.033c -0.176 0 -0.264 -0.088 -0.264 -0.264c 0 -0.099 0.066 -0.143 0.198 -0.154c 0.627 -0.033 0.957 -0.055 0.99 -0.077c 0.033 -0.022 0.044 -0.066 0.044 -0.121c 0 -0.077 -0.077 -0.407 -0.22 -0.979c -0.22 -0.792 -1.034 -1.276 -2.057 -1.276c -1.342 0 -2.145 0.891 -2.145 2.233c 0 0.209 0.022 0.473 0.055 0.77c 0.121 0.902 0.715 2.167 1.188 2.75c 0.55 0.693 1.562 1.386 2.684 1.386c 1.144 0 1.705 -0.869 1.705 -2.057c 0 -0.099 -0.033 -0.451 -0.033 -0.55c 0 -0.099 0.066 -0.154 0.209 -0.154c 0.055 0 0.099 0.011 0.132 0.022c 0.055 0.077 0.088 0.154 0.11 0.231l 0.682 2.783c 0 0.099 -0.055 0.154 -0.165 0.154c -0.044 0 -0.11 -0.044 -0.198 -0.143l -0.715 -0.803c -0.429 0.627 -1.034 0.946 -1.815 0.946c -0.605 0 -1.199 -0.143 -1.804 -0.418c -1.221 -0.572 -2.112 -1.474 -2.684 -2.706c -0.286 -0.605 -0.429 -1.221 -0.429 -1.848c 0 -1.76 1.254 -3.025 3.014 -3.025Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g481AE727E6F914D5199E83A214575C36&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 9.174 7.513c -0.187 0 -0.836 -0.033 -1.023 -0.033c -0.22 0 -0.99 0.033 -1.21 0.033c -0.165 0 -0.253 -0.088 -0.253 -0.264c 0 -0.099 0.055 -0.154 0.176 -0.165c 0.264 -0.033 0.396 -0.121 0.396 -0.286c 0 -0.099 -0.066 -0.22 -0.198 -0.363l -1.716 -1.848c -0.319 0.748 -0.627 1.485 -0.946 2.233c 0.011 0.022 0.022 0.044 0.055 0.066c 0.099 0.11 0.286 0.176 0.55 0.198c 0.176 0.022 0.264 0.11 0.264 0.253c 0 0.121 -0.066 0.176 -0.209 0.176c -0.264 0 -1.111 -0.033 -1.375 -0.033c -0.231 0 -0.99 0.033 -1.221 0.033c -0.165 0 -0.242 -0.088 -0.242 -0.264c 0 -0.11 0.099 -0.165 0.297 -0.165c 0.495 0 0.649 0 0.781 -0.319l 1.276 -3.003l -2.288 -2.453c -0.033 -0.033 -0.077 -0.077 -0.132 -0.11c -0.451 -0.473 -0.968 -0.737 -1.573 -0.77c -0.187 -0.011 -0.286 -0.11 -0.286 -0.275c 0.033 -0.099 0.044 -0.154 0.187 -0.154c 0.187 0 0.836 0.033 1.023 0.033c 0.231 0 0.99 -0.033 1.221 -0.033c 0.165 0 0.242 0.088 0.242 0.264c 0 0.099 -0.055 0.154 -0.176 0.165c -0.264 0.022 -0.396 0.121 -0.396 0.286c 0 0.11 0.099 0.264 0.286 0.462c 0.682 0.726 1.375 1.452 2.046 2.189c 0.374 -0.891 0.759 -1.771 1.122 -2.673c -0.011 -0.022 -0.022 -0.044 -0.055 -0.077c -0.099 -0.099 -0.275 -0.154 -0.539 -0.187c -0.165 -0.022 -0.253 -0.11 -0.253 -0.253c 0 -0.121 0.066 -0.176 0.209 -0.176l 1.375 0.033c 0.231 0 1.001 -0.033 1.199 -0.033c 0.165 0 0.253 0.088 0.253 0.253c 0 0.11 -0.077 0.165 -0.242 0.176c -0.341 0 -0.561 0.011 -0.638 0.055c -0.077 0.044 -0.165 0.176 -0.253 0.396l -1.397 3.333c 0.748 0.792 1.309 1.386 1.672 1.793c 0.264 0.275 0.44 0.462 0.539 0.539c 0.407 0.341 0.858 0.517 1.353 0.539c 0.231 0.011 0.286 0.066 0.286 0.275c -0.033 0.099 -0.044 0.154 -0.187 0.154Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g6F5992FA517D1182004B86DB427D458C&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 7.304 7.48c -0.198 0 -0.88 0.033 -1.089 0.033c -0.165 0 -0.253 -0.088 -0.253 -0.253c 0 -0.121 0.066 -0.176 0.209 -0.176c 0.231 0 0.352 -0.066 0.352 -0.198c 0 -0.121 -0.099 -0.286 -0.286 -0.495l -2.475 -2.849l -1.166 3.157c -0.033 0.088 -0.055 0.143 -0.066 0.176c 0 0.143 0.198 0.209 0.594 0.209c 0.209 0 0.308 0.088 0.308 0.264c 0 0.11 -0.066 0.165 -0.209 0.165l -1.375 -0.033c -0.242 0 -1.012 0.033 -1.21 0.033c -0.165 0 -0.253 -0.088 -0.253 -0.264c 0 -0.11 0.099 -0.165 0.297 -0.165c 0.198 0 0.363 -0.022 0.462 -0.044c 0.209 -0.055 0.22 -0.088 0.286 -0.297l 1.342 -3.575c 0.033 -0.077 0.044 -0.132 0.044 -0.165l -0.231 -0.913c -0.132 -0.561 -0.22 -0.913 -0.264 -1.056c -0.077 -0.297 -0.154 -0.473 -0.231 -0.528c -0.077 -0.055 -0.33 -0.077 -0.748 -0.077c -0.242 -0.011 -0.341 -0.022 -0.341 -0.264c 0 -0.11 0.066 -0.165 0.198 -0.165l 1.375 0.033l 1.386 -0.033c 0.165 -0.011 0.253 0.077 0.253 0.264c 0 0.077 -0.033 0.132 -0.088 0.143c -0.11 0.011 -0.198 0.022 -0.253 0.022c -0.363 0.011 -0.583 0.033 -0.638 0.066c -0.022 0.011 -0.033 0.033 -0.033 0.077c 0 0.044 0.055 0.275 0.154 0.682l 0.385 1.529c 0.033 0.143 0.077 0.253 0.143 0.319l 2.695 3.102l 0.143 0.143c 0.286 0.286 0.55 0.484 0.781 0.583c 0.187 0.088 0.396 0.143 0.627 0.154c 0.198 0.022 0.253 0.077 0.253 0.253c 0 0.121 -0.066 0.176 -0.187 0.176c -0.165 0 -0.726 -0.033 -0.891 -0.033Z &quot;/&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;That is, &lt;math&gt;&lt;msub&gt;&lt;mi&gt;𝜂&lt;/mi&gt;&lt;mi&gt;𝑌&lt;/mi&gt;&lt;/msub&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝐺&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝜂&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/msub&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; This is &lt;strong&gt;naturality&lt;/strong&gt;: the transformation must work the same way no matter which object you look at. Here’s the connection: the free theorems we got from parametricity are naturality conditions in disguise. A polymorphic function in System F is a natural transformation when viewed through the right categorical lens. Parametricity and naturality are two sides of the same coin.&lt;/p&gt;&lt;p&gt;With these three concepts — category, functor, natural transformation — we can finally name the pattern that has been staring at us since the very beginning. An &lt;strong&gt;F-algebra&lt;/strong&gt; is a triple &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; consisting of a functor &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; a carrier type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and a function &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Intuitively, &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; is an &lt;strong&gt;evaluator&lt;/strong&gt; that folds the structure described by &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; into a single value of type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; For example, the functor of natural numbers is &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝𝙵&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; An F-algebra for this functor consists of a type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; and a function &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; By algebraic manipulation, this becomes a pair of functions &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑧&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; where&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;math&gt;&lt;mi&gt;𝑧&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝙻𝚎𝚏𝚝&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; gives what the zero value evaluates to, and&lt;/li&gt;&lt;li&gt;&lt;math&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝚁𝚒𝚐𝚑𝚝&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; maps the evaluation of &lt;math&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;/math&gt; to the evaluation of its successor.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;For &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕𝙵&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; a &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕𝙵&lt;/mtext&gt;&lt;/math&gt;-algebra is simply two values of type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo form=&quot;infix&quot; lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0em&quot;&gt;:&lt;/mo&gt;&lt;/math&gt; the algebra map &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; corresponds to a pair &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/msub&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; where &lt;math&gt;&lt;msub&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/msub&gt;&lt;/math&gt; evaluates &lt;code&gt;true&lt;/code&gt; and &lt;math&gt;&lt;msub&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;/math&gt; evaluates &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;The Church encoding type &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; now acquires a precise meaning: it is a &lt;strong&gt;universal consumer of F-algebras&lt;/strong&gt;: given any F-algebra &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; it takes the evaluator &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; and runs it on the data type’s structure to produce a value of type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; It makes the “consumption interface” idea rigorous.&lt;/p&gt;&lt;p&gt;F-algebras for a fixed functor &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; themselves form a category. An arrow in this category is called an &lt;strong&gt;F-algebra homomorphism&lt;/strong&gt;. If &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; and &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; are two F-algebras, a homomorphism between them is a function &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; that preserves the algebraic structure:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;In diagram form:&lt;/p&gt;&lt;div class=&quot;typst-center&quot;&gt;&lt;span class=&quot;typst-invert&quot;&gt;&lt;svg style=&quot;overflow: visible; width: 9.374953074em; height: 8.637230852em;&quot; viewBox=&quot;0 0 103.124483815 95.00953937&quot; width=&quot;103.124483815pt&quot; height=&quot;95.00953937pt&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; xmlns:h5=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(41.748166667 18.568)&quot; d=&quot;M 0 0l 45.221167008 0&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(84.895876201 18.567999906)&quot; d=&quot;M 0 0m 2.073457535 0c -1.064538428 0.489632971 -1.833840644 1.455047916 -2.073457535 2.602029282&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(84.895876201 15.965970623)&quot; d=&quot;M 0 0m 2.073457535 2.602029282c -1.064538428 -0.489632971 -1.833840644 -1.455047916 -2.073457535 -2.602029282&quot;/&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(59.100750171)&quot; d=&quot;M 0 0h 10.78l 0 14.168h -10.78v -14.168Z &quot;/&gt;&lt;g transform=&quot;translate(59.100750092 -6.3e-8)&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 2.2 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g102A2C163EA38BFB64ACE307643314D7&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(26.127444444 28.324499906)&quot; d=&quot;M 0 0v 52.908039465&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(23.525415162 79.159081614)&quot; d=&quot;M 0 0m 2.602029282 2.073457535c -0.489632971 -1.064538428 -1.455047916 -1.833840644 -2.602029282 -2.073457535&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(26.127444444 79.159081614)&quot; d=&quot;M 0 0m 0 2.073457535c 0.489632971 -1.064538428 1.455047916 -1.833840644 2.602029282 -2.073457535&quot;/&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(0 48.893519638)&quot; d=&quot;M 0 0h 21.727444444v 12.034h -21.727444444v -12.034Z &quot;/&gt;&lt;g transform=&quot;translate(-4.5e-8 48.893519606)&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 2.2 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g7CF395EBAD04303597139525CE722D4&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 13.191444444 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g6F013E8102D3CE54005BADBEC7660725&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(98.812483815 30.14715014)&quot; d=&quot;M 0 0v 49.123092474&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(96.210454627 77.196784827)&quot; d=&quot;M 0 0m 2.602029282 2.073457535c -0.489632971 -1.064538428 -1.455047916 -1.833840644 -2.602029282 -2.073457535&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(98.812483909 77.196784827)&quot; d=&quot;M 0 0m 0 2.073457535c 0.489632971 -1.064538428 1.455047916 -1.833840644 2.602029282 -2.073457535&quot;/&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(83.676483815 48.823696377)&quot; d=&quot;M 0 0h 10.736v 12.034h -10.736v -12.034Z &quot;/&gt;&lt;g transform=&quot;translate(83.676483704 48.823696345)&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 2.2 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g6F013E8102D3CE54005BADBEC7660725&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(41.935166667 91.25303937)&quot; d=&quot;M 0 0h 44.894520494&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(84.756229649 91.25303937)&quot; d=&quot;M 0 0m 2.073457535 0c -1.064538428 0.489632971 -1.833840644 1.455047916 -2.073457535 2.602029282&quot;/&gt;&lt;path fill=&quot;none&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.528&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;miter&quot; stroke-miterlimit=&quot;4&quot; transform=&quot;translate(84.756229649 88.651010088)&quot; d=&quot;M 0 0m 2.073457535 2.602029282c -1.064538428 -0.489632971 -1.833840644 -1.455047916 -2.073457535 -2.602029282&quot;/&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(59.553426914 72.68503937)&quot; d=&quot;M 0 0h 9.922v 14.168h -9.922v -14.168Z &quot;/&gt;&lt;g transform=&quot;translate(59.553426788 72.685039307)&quot;&gt;&lt;g&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 2.2 9.713)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g91C9E26AA50206E7D4B057869560567E&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(16.506722222 14.8115)&quot; d=&quot;M 0 0h 19.241444445v 7.513h -19.241444445v -7.513Z &quot;/&gt;&lt;g transform=&quot;translate(16.506722098 14.811499921)&quot;&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 0 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g7CF395EBAD04303597139525CE722D4&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 10.991444444 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#gF62F9E0771B07FFA68FBC40120773058&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(94.687483814 14.8115)&quot; d=&quot;M 0 0h 8.25v 7.513h -8.25v -7.513Z &quot;/&gt;&lt;g transform=&quot;translate(94.687483767 14.811499921)&quot;&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 0 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#gF62F9E0771B07FFA68FBC40120773058&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(16.319722222 87.49653937)&quot; d=&quot;M 0 0h 19.615444445v 7.513h -19.615444445v -7.513Z &quot;/&gt;&lt;g transform=&quot;translate(16.319722082 87.496539291)&quot;&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 0 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#g7CF395EBAD04303597139525CE722D4&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 10.991444444 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#gCEE79D229BD72B8FDC781FF73852F0D4&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;path fill=&quot;none&quot; transform=&quot;translate(94.500483814 87.49653937)&quot; d=&quot;M 0 0h 8.624v 7.513h -8.624v -7.513Z &quot;/&gt;&lt;g transform=&quot;translate(94.500483752 87.496539291)&quot;&gt;&lt;g&gt;&lt;g transform=&quot;matrix(1 0 0 -1 0 7.513)&quot;&gt;&lt;use xlink:href=&quot;https://blog.wybxc.cc/blog/parametricity/#gCEE79D229BD72B8FDC781FF73852F0D4&quot; x=&quot;0&quot; y=&quot;0&quot; fill=&quot;#000000&quot; fill-rule=&quot;nonzero&quot;/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;defs&gt;&lt;symbol id=&quot;g102A2C163EA38BFB64ACE307643314D7&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 6.072 6.963c 0 0.484 -0.473 0.792 -0.99 0.792c -0.682 0 -1.155 -0.44 -1.408 -1.309c -0.055 -0.198 -0.176 -0.759 -0.352 -1.683h -0.715c -0.242 0 -0.363 -0.011 -0.363 -0.242c 0 -0.121 0.11 -0.176 0.341 -0.176h 0.66l -0.803 -4.257c -0.121 -0.627 -0.231 -1.089 -0.33 -1.397c -0.132 -0.407 -0.319 -0.616 -0.561 -0.616c -0.165 0 -0.297 0.044 -0.418 0.121c 0.352 0.055 0.528 0.264 0.528 0.616c 0 0.286 -0.143 0.429 -0.44 0.429c -0.374 0 -0.638 -0.33 -0.638 -0.704c 0 -0.484 0.451 -0.792 0.968 -0.792c 0.275 0 0.528 0.11 0.737 0.341c 0.352 0.363 0.627 0.88 0.825 1.573c 0.121 0.429 0.231 0.847 0.308 1.265l 0.638 3.421h 0.902c 0.253 0 0.363 0.011 0.363 0.264c 0 0.099 -0.11 0.154 -0.33 0.154h -0.847c 0.066 0.451 0.374 2.112 0.473 2.321c 0.11 0.231 0.264 0.341 0.462 0.341c 0.165 0 0.308 -0.044 0.429 -0.121c -0.341 -0.077 -0.517 -0.275 -0.517 -0.616c 0 -0.286 0.143 -0.429 0.44 -0.429c 0.374 0 0.638 0.33 0.638 0.704Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g7CF395EBAD04303597139525CE722D4&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 2.189 7.216c 0 -0.11 0.121 -0.165 0.352 -0.165c 0.44 0 0.66 -0.044 0.66 -0.143c 0 -0.033 -0.022 -0.11 -0.055 -0.253l -1.43 -5.753c -0.066 -0.242 -0.176 -0.385 -0.33 -0.44c -0.077 -0.022 -0.275 -0.033 -0.616 -0.033c -0.242 0 -0.352 -0.022 -0.352 -0.253c 0 -0.121 0.066 -0.176 0.209 -0.176l 1.43 0.033l 1.628 -0.033c 0.176 0 0.264 0.088 0.264 0.253c 0 0.187 -0.121 0.176 -0.407 0.176c -0.484 0 -0.759 0.022 -0.825 0.077c -0.033 0.011 -0.044 0.055 -0.044 0.11l 0.704 2.915h 1.023c 0.506 0 0.858 -0.022 0.858 -0.44c 0 -0.143 -0.022 -0.319 -0.077 -0.528c -0.011 -0.033 -0.022 -0.077 -0.033 -0.121c 0 -0.121 0.055 -0.176 0.176 -0.176c 0.055 0.011 0.132 0.088 0.209 0.253l 0.594 2.365c 0.022 0.088 0.033 0.154 0.033 0.187c -0.033 0.099 -0.099 0.154 -0.176 0.154c -0.088 0 -0.154 -0.088 -0.198 -0.253c -0.11 -0.418 -0.264 -0.682 -0.44 -0.814c -0.176 -0.132 -0.484 -0.198 -0.924 -0.198h -0.935l 0.682 2.706c 0.088 0.374 0.088 0.385 0.55 0.385h 1.43c 1.067 0 1.551 -0.165 1.551 -1.144c 0 -0.22 -0.011 -0.418 -0.033 -0.583c -0.011 -0.121 -0.022 -0.187 -0.022 -0.198c 0 -0.121 0.055 -0.176 0.165 -0.176c 0.11 0 0.176 0.099 0.198 0.308l 0.22 1.881c 0.033 0.308 -0.044 0.341 -0.341 0.341h -5.324c -0.253 0 -0.374 -0.011 -0.374 -0.264Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g6F013E8102D3CE54005BADBEC7660725&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 5.632 1.518c -0.253 -0.869 -0.605 -1.309 -1.067 -1.309c -0.143 0 -0.22 0.099 -0.22 0.308c 0 0.165 0.066 0.418 0.198 0.759c 0.44 1.177 0.66 1.98 0.66 2.409c 0 0.781 -0.506 1.21 -1.287 1.21c -0.583 0 -1.089 -0.242 -1.518 -0.715l 0.803 3.289c -0.022 0.099 -0.044 0.165 -0.187 0.165c -0.363 0 -1.166 -0.099 -1.309 -0.11c -0.165 -0.022 -0.253 -0.099 -0.253 -0.264c 0 -0.11 0.099 -0.165 0.297 -0.165c 0.231 0 0.484 0.011 0.506 -0.143l -1.606 -6.479c -0.033 -0.121 -0.044 -0.198 -0.044 -0.242c 0 -0.231 0.121 -0.352 0.352 -0.352c 0.22 0 0.374 0.11 0.451 0.319l 0.44 1.804c 0.132 0.539 0.231 0.946 0.308 1.221c 0.033 0.077 0.121 0.231 0.264 0.451c 0.396 0.594 0.88 0.891 1.463 0.891c 0.363 0 0.539 -0.242 0.539 -0.715c 0 -0.451 -0.22 -1.254 -0.66 -2.42c -0.099 -0.253 -0.143 -0.451 -0.143 -0.616c 0 -0.528 0.396 -0.935 0.924 -0.935c 0.484 0 0.869 0.275 1.144 0.836c 0.209 0.44 0.319 0.737 0.319 0.88c 0 0.099 -0.055 0.154 -0.176 0.154c -0.033 0 -0.198 -0.099 -0.198 -0.231Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;g91C9E26AA50206E7D4B057869560567E&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 0.165 -1.551c 0 -0.473 0.495 -0.704 1.485 -0.704c 0.517 0 1.001 0.132 1.43 0.385c 0.484 0.286 0.781 0.671 0.902 1.144l 1.199 4.829c 0.022 0.11 0.033 0.176 0.033 0.209c 0 0.22 -0.121 0.33 -0.352 0.33c -0.242 0 -0.396 -0.132 -0.473 -0.385c -0.242 0.407 -0.572 0.605 -0.979 0.605c -0.704 0 -1.331 -0.352 -1.87 -1.056c -0.495 -0.66 -0.748 -1.353 -0.748 -2.068c 0 -0.957 0.561 -1.771 1.485 -1.771c 0.429 0 0.825 0.187 1.188 0.55l -0.33 -1.298c -0.319 -0.759 -0.814 -1.144 -1.507 -1.144c -0.286 0 -0.528 0.022 -0.726 0.066c 0.231 0.121 0.341 0.308 0.341 0.561c 0 0.275 -0.154 0.418 -0.451 0.418c -0.352 0 -0.627 -0.319 -0.627 -0.671Z m 3.751 5.863c 0.22 -0.231 0.33 -0.451 0.33 -0.671c 0 -0.011 -0.011 -0.066 -0.033 -0.143l -0.517 -2.079c -0.066 -0.253 -0.253 -0.517 -0.55 -0.759c -0.297 -0.242 -0.583 -0.363 -0.836 -0.363c -0.44 0 -0.66 0.319 -0.66 0.957c 0 0.605 0.374 1.947 0.594 2.343c 0.341 0.627 0.726 0.935 1.177 0.935c 0.198 0 0.363 -0.077 0.495 -0.22Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;gF62F9E0771B07FFA68FBC40120773058&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 1.507 0.033c 0.198 0 0.88 -0.033 1.089 -0.033c 0.165 0 0.242 0.088 0.242 0.253c 0 0.099 -0.066 0.165 -0.209 0.176c -0.319 0.011 -0.473 0.121 -0.473 0.33c 0 0.099 0.099 0.319 0.308 0.649c 0.297 0.495 0.506 0.858 0.649 1.1h 2.673c 0 -0.077 0.011 -0.231 0.044 -0.473c 0.077 -0.803 0.121 -1.243 0.121 -1.298c 0 -0.209 -0.242 -0.308 -0.737 -0.308c -0.209 0 -0.308 -0.088 -0.308 -0.264c 0 -0.11 0.066 -0.165 0.198 -0.165c 0.264 0 1.1 0.033 1.364 0.033c 0.22 0 1.001 -0.033 1.221 -0.033c 0.165 0 0.242 0.088 0.242 0.264c 0 0.11 -0.099 0.165 -0.297 0.165c -0.308 0 -0.495 0.022 -0.55 0.055c -0.055 0.033 -0.099 0.132 -0.11 0.297l -0.66 6.798c -0.033 0.209 -0.022 0.297 -0.253 0.297c -0.132 0 -0.242 -0.066 -0.319 -0.209l -3.784 -6.347c -0.33 -0.55 -0.77 -0.847 -1.309 -0.891c -0.176 -0.011 -0.264 -0.099 -0.264 -0.264c 0 -0.11 0.066 -0.165 0.187 -0.165c 0.176 0 0.759 0.033 0.935 0.033Z m 3.905 6.314l 0.33 -3.41h -2.365Z &quot;/&gt;&lt;/symbol&gt;&lt;symbol id=&quot;gCEE79D229BD72B8FDC781FF73852F0D4&quot; overflow=&quot;visible&quot;&gt;&lt;path d=&quot;M 0 0m 8.316 5.973c 0 1.001 -0.99 1.54 -2.068 1.54h -3.652c -0.253 0 -0.363 -0.011 -0.363 -0.264c 0 -0.176 0.22 -0.165 0.352 -0.165c 0.33 -0.011 0.528 -0.033 0.583 -0.044c 0.055 -0.011 0.077 -0.044 0.077 -0.099c 0 -0.022 -0.011 -0.088 -0.044 -0.198l -1.452 -5.841c -0.055 -0.242 -0.165 -0.385 -0.33 -0.44c -0.077 -0.022 -0.275 -0.033 -0.616 -0.033c -0.231 0 -0.341 -0.088 -0.341 -0.264c 0 -0.11 0.11 -0.165 0.341 -0.165h 3.883c 0.715 0 1.375 0.22 2.002 0.649c 0.693 0.473 1.045 1.056 1.045 1.738c 0 0.869 -0.715 1.397 -1.496 1.551c 0.968 0.231 2.079 0.968 2.079 2.035Z m -2.222 1.111c 0.759 0 1.144 -0.352 1.144 -1.067c 0 -0.561 -0.22 -1.023 -0.682 -1.397c -0.462 -0.374 -0.979 -0.55 -1.54 -0.55h -1.529l 0.66 2.64c 0.088 0.374 0.088 0.374 0.55 0.374Z m 0.308 -3.795c 0.154 -0.253 0.231 -0.506 0.231 -0.781c 0 -0.572 -0.22 -1.067 -0.671 -1.474c -0.451 -0.407 -0.957 -0.605 -1.54 -0.605h -1.485c -0.11 0 -0.187 0 -0.231 0.011c -0.066 0 -0.099 0.022 -0.099 0.055c 0 0.011 0 0.044 0.011 0.088c 0.341 1.397 0.605 2.453 0.781 3.157h 2.024c 0.473 0 0.792 -0.154 0.979 -0.451Z &quot;/&gt;&lt;/symbol&gt;&lt;/defs&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;The condition says: evaluating a structure in &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; and then translating the result to &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; yields the same value as translating the sub-structure to &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/math&gt; first and then evaluating in &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; The two paths through the square produce the same result.&lt;/p&gt;&lt;p&gt;For example, for &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝𝙵&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; the homomorphism condition becomes:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtable class=&quot;multiline-equation aligned&quot;&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝑧&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mo form=&quot;infix&quot;&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝑧&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mo form=&quot;infix&quot;&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑎&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;/mtable&gt;&lt;/math&gt;&lt;p&gt;These two equations are exactly the pattern that any structural recursion must obey: the base case maps to the base case, and the recursive case applies &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;/math&gt; to the predecessor and then the successor function.&lt;/p&gt;&lt;h3 id=&quot;loc-6&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-6&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Initial Algebra&lt;/h3&gt;&lt;p&gt;Among the F-algebras for a given functor &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; one deserves special attention. In a category, an &lt;strong&gt;initial object&lt;/strong&gt; satisfies the &lt;strong&gt;initiality&lt;/strong&gt; property: there is a unique arrow from it to every other object. In the category of F-algebras, the initial object is called the &lt;strong&gt;initial algebra&lt;/strong&gt;, written &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; where &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; is the carrier and &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; is the structure map.&lt;/p&gt;&lt;p&gt;By initiality, for any F-algebra &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; there is exactly one homomorphism from &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; to it. We call it &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;To get an intuitive grasp of what the initial algebra is, let’s look at the type of &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;/math&gt; in System F. It takes an evaluator &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; and returns a function &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; So its type signature is &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Compare this with the Church encoding type: &lt;math&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; They are almost identical. The only difference is that &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;/math&gt; has an extra &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo form=&quot;infix&quot; rspace=&quot;0em&quot; stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;/math&gt; tucked before the final &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Where Church encoding takes an algebra and produces an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; fold takes an algebra &lt;em&gt;and&lt;/em&gt; a &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; value to produce an &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;This suggests a natural way to move between &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Given &lt;math&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; we can partially apply &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;/math&gt; to get a Church encoding: &lt;math&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;Λ&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mi&gt;𝜆&lt;/mi&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Conversely, given &lt;math&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; we can feed it the initial algebra’s own structure map: &lt;math&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; These two maps point at each other: one wraps a &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; value into a universal consumer, the other unwraps a universal consumer by running it on the initial algebra itself. We’ll prove they are inverses, establishing &lt;math&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Before we do, we still need to understand what &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; actually is. For that we return to initiality. Take the object &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; and turn it into an F-algebra by using &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; as the structure map. By initiality, we get a unique homomorphism from &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; to this new algebra; call it &lt;math&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; But &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/math&gt; itself is a homomorphism in the opposite direction: &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Compose the two: &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;/math&gt; is a homomorphism from &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; to itself. Initiality says there is exactly one such homomorphism, namely &lt;math&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; so &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; The same argument on the other side gives &lt;math&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; So &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;/math&gt; are inverses: &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/math&gt; is an isomorphism.&lt;/p&gt;&lt;p&gt;This is &lt;strong&gt;Lambek’s theorem&lt;/strong&gt;: &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; The carrier of the initial algebra is the recursive type &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; That is why we choose the notation &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Now that we know &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; is a recursive type, the role of the structure map &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/math&gt; becomes clear. It is a constructor that builds the recursive type from its components. Take &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;/math&gt; as an example, &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;/math&gt; has two cases:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;math&gt;&lt;mtext&gt;𝙻𝚎𝚏𝚝&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; means no predecessor: &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/math&gt; returns &lt;math&gt;&lt;mtext&gt;𝚉𝚎𝚛𝚘&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;;&lt;/mo&gt;&lt;/math&gt;&lt;/li&gt;&lt;li&gt;&lt;math&gt;&lt;mtext&gt;𝚁𝚒𝚐𝚑𝚝&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;/math&gt; means one predecessor &lt;math&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;/math&gt; already built: &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/math&gt; returns &lt;math&gt;&lt;mtext&gt;𝚂𝚞𝚌𝚌&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The fold equation now also becomes concrete. An algebra &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; expands to a pair &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑧&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and the equation &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; becomes:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtable class=&quot;multiline-equation aligned&quot;&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mtext&gt;𝚉𝚎𝚛𝚘&lt;/mtext&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mo form=&quot;infix&quot;&gt;=&lt;/mo&gt;&lt;mi&gt;𝑧&lt;/mi&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝚂𝚞𝚌𝚌&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mo form=&quot;infix&quot;&gt;=&lt;/mo&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑛&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;/mtable&gt;&lt;/math&gt;&lt;p&gt;This is structural recursion: replace every &lt;math&gt;&lt;mtext&gt;𝚉𝚎𝚛𝚘&lt;/mtext&gt;&lt;/math&gt; with &lt;math&gt;&lt;mi&gt;𝑧&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; every &lt;math&gt;&lt;mtext&gt;𝚂𝚞𝚌𝚌&lt;/mtext&gt;&lt;/math&gt; with an application of &lt;math&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;/math&gt; to the recursively processed predecessor. The fold walks through the value from the bottom up, substituting each constructor with the algebra’s interpretation.&lt;/p&gt;&lt;p&gt;One more consequence of initiality: &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Since &lt;math&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;/math&gt; is a homomorphism from the initial algebra to itself, and initiality says there can only be one, the fold at the initial algebra’s own structure map must be the identity. This equation unlocks the proof.&lt;/p&gt;&lt;p&gt;Stepping back: &lt;math&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/math&gt; builds values from nothing. &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;/math&gt; takes those values and interprets them in any algebra you choose, uniquely. One end generates; the other end consumes. We call this a &lt;strong&gt;universal producer&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;The Church encoding &lt;math&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; is the mirror image: it takes any algebra and returns a value: a &lt;strong&gt;universal consumer&lt;/strong&gt;. Universal producer meets universal consumer.&lt;/p&gt;&lt;p&gt;They are.&lt;/p&gt;&lt;p&gt;Let’s prove &lt;math&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; We define two functions between them in System F, and show that they are inverses of each other:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;fromChurch : ChurchF → μ F
fromChurch c = c [μ F] in

toChurch : μ F → ChurchF
toChurch x = ΛX. λ(f : F X → X). fold f x&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;math&gt;&lt;mtext&gt;𝚏𝚛𝚘𝚖𝙲𝚑𝚞𝚛𝚌𝚑&lt;/mtext&gt;&lt;/math&gt; feeds the initial algebra to the universal consumer. &lt;math&gt;&lt;mtext&gt;𝚝𝚘𝙲𝚑𝚞𝚛𝚌𝚑&lt;/mtext&gt;&lt;/math&gt; takes a concrete value and turns it into a consumer by folding over any algebra you give it.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step one:&lt;/strong&gt; &lt;math&gt;&lt;mtext&gt;𝚏𝚛𝚘𝚖𝙲𝚑𝚞𝚛𝚌𝚑&lt;/mtext&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mtext&gt;𝚝𝚘𝙲𝚑𝚞𝚛𝚌𝚑&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; For any &lt;math&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo form=&quot;infix&quot; lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0em&quot;&gt;:&lt;/mo&gt;&lt;/math&gt;&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtable class=&quot;multiline-equation aligned&quot;&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mtext&gt;𝚏𝚛𝚘𝚖𝙲𝚑𝚞𝚛𝚌𝚑&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝚝𝚘𝙲𝚑𝚞𝚛𝚌𝚑&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mo lspace=&quot;0em&quot;&gt;=&lt;/mo&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mtext&gt;𝚝𝚘𝙲𝚑𝚞𝚛𝚌𝚑&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mo lspace=&quot;0em&quot;&gt;=&lt;/mo&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;mtr&gt;&lt;mtd&gt;&lt;mo lspace=&quot;0em&quot;&gt;=&lt;/mo&gt;&lt;/mtd&gt;&lt;mtd&gt;&lt;mi&gt;𝑥&lt;/mi&gt;&lt;/mtd&gt;&lt;/mtr&gt;&lt;/mtable&gt;&lt;/math&gt;&lt;p&gt;&lt;strong&gt;Step two:&lt;/strong&gt; &lt;math&gt;&lt;mtext&gt;𝚝𝚘𝙲𝚑𝚞𝚛𝚌𝚑&lt;/mtext&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mtext&gt;𝚏𝚛𝚘𝚖𝙲𝚑𝚞𝚛𝚌𝚑&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;We need to show that for any &lt;math&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; any &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and any &lt;math&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo form=&quot;infix&quot; lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0em&quot;&gt;:&lt;/mo&gt;&lt;/math&gt;&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;This is where parametricity pays off. Recall the free theorem: for any F-algebra homomorphism &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt;&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;/math&gt;&lt;p&gt;Let &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Since &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/math&gt; is an algebra homomorphism, the free theorem applies directly:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;That’s the equality we needed. Both directions are inverses, so &lt;math&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Two independent ideas: the uniqueness of the fold from the initial algebra and the free theorem from parametricity, interlocked to deliver the isomorphism.&lt;/p&gt;&lt;p&gt;We’ve proved the isomorphism. But a question lingers: &lt;strong&gt;why&lt;/strong&gt; this shape? Why &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt;? We arrived at it by following our noses through &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and a bit of algebra. That’s a fine derivation, but it doesn’t explain why the shape &lt;strong&gt;must&lt;/strong&gt; be what it is. For that, we turn to what is arguably the &lt;em&gt;most beautiful&lt;/em&gt; theorem in category theory.&lt;/p&gt;&lt;h3 id=&quot;loc-7&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-7&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;The Yoneda Lemma&lt;/h3&gt;&lt;p&gt;Before stating the lemma, one more piece of vocabulary. The &lt;strong&gt;Hom-functor&lt;/strong&gt; &lt;math&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;−&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; embodies “the view from &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;” For any object &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; is the set of all arrows from &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; to &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; which in &lt;math&gt;&lt;mtext&gt;𝐒𝐞𝐭&lt;/mtext&gt;&lt;/math&gt; is just the function type &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Given a function &lt;math&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑌&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; the Hom-functor maps it by post-composition: &lt;math&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝜆&lt;/mi&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;mo lspace=&quot;0.2222222222222222em&quot; rspace=&quot;0.2222222222222222em&quot;&gt;∘&lt;/mo&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Formally: “everything you can do with an &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;”&lt;/p&gt;&lt;p&gt;Now the Yoneda Lemma:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;For any (locally small) category &lt;math&gt;&lt;mi&gt;𝒞︀&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; any object &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; in &lt;math&gt;&lt;mi&gt;𝒞︀&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and any &lt;math&gt;&lt;mtext&gt;𝐒𝐞𝐭&lt;/mtext&gt;&lt;/math&gt;-valued functor &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mi&gt;𝒞︀&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mtext&gt;𝚂𝚎𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; there exists a bijection:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtext&gt;𝖭𝖺𝗍&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;−&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt;&lt;p&gt;The left side is the set of natural transformations from &lt;math&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;−&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; to &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;;&lt;/mo&gt;&lt;/math&gt; the right side is the value of &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; at &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; This bijection is natural in both &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Beneath the formalism, the idea is simple. A natural transformation from &lt;math&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;−&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; to &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; is completely determined by a single choice: where you send &lt;math&gt;&lt;msub&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Pick any element of &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; as the image of &lt;math&gt;&lt;msub&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and naturality does the rest — it uniquely transports that choice to every other object. Conversely, given a natural transformation, applying it to &lt;math&gt;&lt;msub&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;/math&gt; picks out an element of &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; That’s the whole correspondence.&lt;/p&gt;&lt;p&gt;The Hom-functor captures everything you can arrow out of &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; — the “outward view” of &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Yoneda says this outward view &lt;strong&gt;completely determines&lt;/strong&gt; &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; itself. Sound familiar? It’s the categorical incarnation of our consumption-interface principle: a type is fully characterized by how you can consume it.&lt;/p&gt;&lt;p&gt;Let’s make this concrete. Set &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; to the identity functor &lt;math&gt;&lt;mtext&gt;𝙸𝚍&lt;/mtext&gt;&lt;/math&gt; where &lt;math&gt;&lt;mtext&gt;𝙸𝚍&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;𝒞︀&lt;/mi&gt;&lt;/math&gt; to the &lt;math&gt;&lt;mtext&gt;𝐒𝐞𝐭&lt;/mtext&gt;&lt;/math&gt; category. The Yoneda lemma specializes to:&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtext&gt;𝖭𝖺𝗍&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;−&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝙸𝚍&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;Unpacking the left side: &lt;math&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; is &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; A natural transformation &lt;math&gt;&lt;mi&gt;𝜂&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;−&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mtext&gt;𝙸𝚍&lt;/mtext&gt;&lt;/math&gt; is a family of functions &lt;math&gt;&lt;msub&gt;&lt;mi&gt;𝜂&lt;/mi&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/msub&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; one for each &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; So &lt;math&gt;&lt;mi&gt;𝜂&lt;/mi&gt;&lt;/math&gt; is necessarily a polymorphic function in System F. Its type is &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; So &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Yoneda gives us the isomorphism directly.&lt;/p&gt;&lt;p&gt;For &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; this says &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; which simplifies to &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; For &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; we get &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; These are exactly the Church encodings we derived by hand. Now they fall out of Yoneda for free.&lt;/p&gt;&lt;p&gt;But there’s a catch. This only works for non-recursive types: &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/math&gt; is a fixed type, not a recursive definition. To capture &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝&lt;/mtext&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝙻𝚒𝚜𝚝&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; we need to level up.&lt;/p&gt;&lt;p&gt;Instead of the category of types, we work in the &lt;strong&gt;category of F-algebras&lt;/strong&gt;. The objects are F-algebras &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and the arrows are homomorphisms. In this category, the initial algebra &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; is a distinguished object. Its Hom-functor &lt;math&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;−&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; maps any algebra &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; to the set of homomorphisms from the initial algebra to it. By initiality, that set contains exactly one element: &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Now introduce the &lt;strong&gt;forgetful functor&lt;/strong&gt; &lt;math&gt;&lt;mi&gt;𝑈&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; which takes an algebra &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; and discards the structure, keeping only the carrier &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; It’s a functor from the F-algebra category to &lt;math&gt;&lt;mtext&gt;𝐒𝐞𝐭&lt;/mtext&gt;&lt;/math&gt; category.&lt;/p&gt;&lt;p&gt;Apply Yoneda with &lt;math&gt;&lt;mi&gt;𝒞︀&lt;/mi&gt;&lt;/math&gt; as the category of F-algebras, &lt;math&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; and &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑈&lt;/mi&gt;&lt;mo form=&quot;infix&quot; lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0em&quot;&gt;:&lt;/mo&gt;&lt;/math&gt;&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mtext&gt;𝖭𝖺𝗍&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mo form=&quot;prefix&quot;&gt;−&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑈&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝑈&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt;&lt;p&gt;Let’s decode the left side. A natural transformation here gives, for each F-algebra &lt;math&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; a function from &lt;math&gt;&lt;mtext&gt;𝖧𝗈𝗆&lt;/mtext&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; to &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; But that Hom-set is a singleton, it contains only &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; So specifying this function is equivalent to picking a value of type &lt;math&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; for each algebra. Let’s call it &lt;math&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; The naturality condition, with the algebra homomorphisms as arrows, becomes exactly:&lt;/p&gt;&lt;blockquote&gt;For any algebra homomorphism &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mo lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0.2777777777777778em&quot;&gt;:&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;⟨&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑌&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;⟩&lt;/mo&gt;&lt;/mrow&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝑌&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑔&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/blockquote&gt;&lt;p&gt;So the inhabitants of &lt;math&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;/math&gt; correspond precisely to the natural transformations on the left side of the Yoneda bijection. By Yoneda, they are in one-to-one correspondence with &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Therefore &lt;math&gt;&lt;mtext&gt;𝙲𝚑𝚞𝚛𝚌𝚑𝙵&lt;/mtext&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; The universal shape of Church encoding, &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; is the Yoneda representation of the initial algebra over the forgetful functor.&lt;/p&gt;&lt;p&gt;So the Church encoding is Yoneda in disguise. &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; is the left side of the Yoneda bijection for the initial algebra over the forgetful functor, and Yoneda guarantees it’s isomorphic to &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;Parametricity and Yoneda are the same idea in two different languages. The free theorem &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;/math&gt; is the Yoneda naturality square, instantiated in the category of F-algebras. The key proof step &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;/math&gt; is Yoneda’s central move: determining the entire natural transformation from a single choice at &lt;math&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;sup&gt;8&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;8.&lt;/span&gt;&lt;span&gt;The two proofs run in parallel: &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;/math&gt; is the naturality square applied to the homomorphism &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mo rspace=&quot;0em&quot;&gt;;&lt;/mo&gt;&lt;/math&gt; &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;/math&gt; corresponds to Yoneda’s key step where &lt;math&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;/math&gt; determines the entire transformation. One path lives inside the type system; the other sits at a higher categorical level. They’re two views of the same structure.&lt;/span&gt;&lt;/span&gt; Parametricity is the type-theoretic shadow of categorical naturality.&lt;/p&gt;&lt;h3 id=&quot;loc-8&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/parametricity/#loc-8&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;The Final Recap&lt;/h3&gt;&lt;p&gt;Church encoding begins with a simple intuition: a data type can be replaced by the way you consume it. From &lt;math&gt;&lt;mtext&gt;𝚄𝚗𝚒𝚝&lt;/mtext&gt;&lt;/math&gt; and &lt;math&gt;&lt;mtext&gt;𝙱𝚘𝚘𝚕&lt;/mtext&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt; this yields types like &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; and &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; To handle recursive types, we introduce functors &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; that describe a data type’s one-layer structure, unifying all Church encodings under a single shape: &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;The inner part &lt;math&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/math&gt; is an &lt;strong&gt;F-algebra&lt;/strong&gt;, and the Church encoding is the universal consumer of F-algebras: it takes any algebra and produces a value. Among all F-algebras, the initial algebra &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; (the recursive data type itself) is the key one: its unique fold operation gives us &lt;math&gt;&lt;mtext&gt;𝚏𝚘𝚕𝚍&lt;/mtext&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mtext&gt;𝚒𝚗&lt;/mtext&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mtext&gt;𝚒𝚍&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Meanwhile, parametricity forces polymorphic functions to behave as natural transformations, yielding the free theorem &lt;math&gt;&lt;mi&gt;ℎ&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐴&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝑐&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;[&lt;/mo&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;mo&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;msub&gt;&lt;mi&gt;𝑓&lt;/mi&gt;&lt;mi&gt;𝐵&lt;/mi&gt;&lt;/msub&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; These two facts — one from initiality, one from parametricity — interlock to prove that Church encoding is isomorphic to the original data type: &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo&gt;≅&lt;/mo&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt;&lt;/p&gt;&lt;p&gt;The Yoneda Lemma tells us why. Applied in the category of F-algebras, Yoneda states that the natural transformations from the Hom-functor out of the initial algebra to the forgetful functor are isomorphic to &lt;math&gt;&lt;mi&gt;𝜇&lt;/mi&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;/math&gt; itself, and those natural transformations are precisely the inhabitants of &lt;math&gt;&lt;mo&gt;∀&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝐹&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;→&lt;/mo&gt;&lt;mi&gt;𝑋&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; The Church encoding is a direct consequence of one of category theory’s most fundamental results. Parametricity and Yoneda are two views of the same structure: both rest on naturality, and one is the type-theoretic shadow of the other.&lt;/p&gt;&lt;p&gt;Returning to the Church numeral &lt;math&gt;&lt;mi&gt;𝜆&lt;/mi&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝜆&lt;/mi&gt;&lt;mi&gt;𝑧&lt;/mi&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;𝑠&lt;/mi&gt;&lt;mspace width=&quot;0.2222em&quot;/&gt;&lt;mi&gt;𝑧&lt;/mi&gt;&lt;/mrow&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mo form=&quot;infix&quot; lspace=&quot;0.2777777777777778em&quot; rspace=&quot;0em&quot;&gt;:&lt;/mo&gt;&lt;/math&gt; it is the Church representation of the initial algebra for the functor &lt;math&gt;&lt;mtext&gt;𝙽𝚊𝚝𝙵&lt;/mtext&gt;&lt;mi&gt;.&lt;/mi&gt;&lt;/math&gt; Church encoding is an elegant tool in programming, and its shape can be traced along a repeatable path from the consumption intuition all the way to the deep structure of category theory.&lt;/p&gt;&lt;section role=&quot;doc-bibliography&quot;&gt;&lt;ul style=&quot;list-style-type: none&quot;&gt;&lt;/ul&gt;&lt;/section&gt;&lt;/article&gt;</content>
  </entry>
  <entry>
    <title>Native Typst to MathML in My Blog</title>
    <id>https://blog.wybxc.cc/blog/mathml/</id>
    <link href="https://blog.wybxc.cc/blog/mathml/"/>
    <published>2026-05-17T00:00:00Z</published>
    <updated>2026-05-17T00:00:00Z</updated>
    <content type="html" xml:base="https://blog.wybxc.cc/blog/mathml/">&lt;article&gt;&lt;aside class&gt;&lt;p&gt;May 17, 2026&lt;br&gt;4 mins read&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;&lt;nav role=&quot;doc-toc&quot;&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/mathml/#loc-1&quot;&gt;Native Typst to MathML in My Blog&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/nav&gt;&lt;/aside&gt;&lt;h2 id=&quot;loc-1&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/mathml/#loc-1&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Native Typst to MathML in My Blog&lt;/h2&gt;&lt;p&gt;Quick update: math equations on my blog are now rendered using &lt;strong&gt;native&lt;/strong&gt; Typst-to-MathML conversion!&lt;/p&gt;&lt;p&gt;Last year, when Typst enhanced its HTML export in version 0.14, I redesigned my blog to use Typst for authoring content. At the time, though, Typst’s HTML export didn’t support math equations. The workaround was to render them as SVG images, which preserved the visual quality but came with several drawbacks: (1) the equations weren’t selectable, (2) they didn’t scale well across different font sizes, (3) they broke in dark mode, and (4) they couldn’t line-wrap to fit the surrounding typography. So I ended up using a third-party library called &lt;a href=&quot;https://codeberg.org/akida/mathyml&quot;&gt;mathyml&lt;/a&gt; to convert math equations into MathML. &lt;sup&gt;1&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;1.&lt;/span&gt;&lt;span&gt;It hooks into Typst’s &lt;code&gt;#show&lt;/code&gt; rule to extract the structured math content, and while its feature coverage is limited, it handles most everyday cases just fine.&lt;/span&gt;&lt;/span&gt; It served me well, but I was still hoping for a proper built-in solution.&lt;/p&gt;&lt;p&gt;I’d been keeping an eye on the progress of native MathML support (&lt;a href=&quot;https://github.com/typst/typst/pull/7436&quot;&gt;#7436&lt;/a&gt;) in Typst, and on May 12, 2026, the PR finally got merged. With this feature, Typst can directly emit math equations as MathML during HTML export. Fantastic news for my blog! Naturally, I decided to upgrade and switch to native MathML rendering.&lt;/p&gt;&lt;p&gt;There’s just one catch: the feature hasn’t landed in a stable Typst release yet, and understandably it’s not available in the downstream libraries that power my blog either. So I had to build those libraries myself against the latest Typst. Turns out it wasn’t as straightforward as I’d hoped. Let me explain.&lt;/p&gt;&lt;p&gt;I use &lt;a href=&quot;https://github.com/OverflowCat/astro-typst&quot;&gt;astro-typst&lt;/a&gt; to integrate Typst into Astro, which in turn uses &lt;a href=&quot;https://github.com/Myriad-Dreamin/typst.ts&quot;&gt;typst.ts&lt;/a&gt; as the underlying Typst engine. Typst.ts shares a lot of code with &lt;a href=&quot;https://github.com/Myriad-Dreamin/tinymist&quot;&gt;tinymist&lt;/a&gt;, the Typst LSP service. Both projects had pinned their Typst dependency to 0.14, and since then Typst’s APIs have gone through a fair number of breaking changes. So the upgrade was decidedly non-trivial. It touched a lot of code across both typst.ts and tinymist.&lt;/p&gt;&lt;p&gt;My plan was to fork typst.ts, bump its pinned Typst version to the latest main branch, and vendor in some of tinymist’s code to get everything working. &lt;sup&gt;2&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;2.&lt;/span&gt;&lt;span&gt;Admittedly, this is not the cleanest approach. It pretty much rules out contributing these changes back upstream. But honestly, I don’t have much bandwidth to maintain a fork properly; I just wanted things to work for my blog, and for now that’s good enough.&lt;/span&gt;&lt;/span&gt; With assistance from Claude Code and DeepSeek V4 Pro, I managed to finish the whole upgrade in a single day. &lt;sup&gt;3&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;3.&lt;/span&gt;&lt;span&gt;I have to say, having an AI assistant tag-team a Rust codebase across multiple crates is quite the experience.&lt;/span&gt;&lt;/span&gt; Now my blog renders math equations using native Typst-to-MathML conversion, and it works beautifully.&lt;/p&gt;&lt;p&gt;If you’d also like to use the bleeding-edge Typst in your own project, feel free to check out my fork of typst.ts at &lt;a href=&quot;https://github.com/Wybxc/typst.ts/tree/wybxc&quot;&gt;GitHub&lt;/a&gt;. Or, if you’re using pnpm, you can simply override the dependency with my pre-built version:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;overrides&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&quot;@myriaddreamin/typst-ts-node-compiler&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&quot;npm:@wybxc/typst-ts-node-compiler@0.7.1&quot;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&quot;@myriaddreamin/typst-ts-renderer&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&quot;npm:@wybxc/typst-ts-renderer@0.7.1&quot;&lt;/span&gt;&lt;span&gt;
  &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&quot;@myriaddreamin/typst.ts&quot;&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&quot;npm:@wybxc/typst.ts@0.7.1&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Below are a few sample math equations to give you a sense of the rendering quality with native Typst-to-MathML conversion:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;The Poincaré–Birkhoff–Witt theorem is a fundamental result in Lie theory that connects the symmetric algebra and the universal enveloping algebra. Let &lt;math&gt;&lt;mi&gt;𝔤&lt;/mi&gt;&lt;/math&gt; be a Lie algebra over a field &lt;math&gt;&lt;mi&gt;𝔽&lt;/mi&gt;&lt;/math&gt;, and let &lt;math&gt;&lt;mi&gt;𝒰︀&lt;/mi&gt;&lt;mo form=&quot;prefix&quot; stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;𝔤&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/math&gt; be its universal enveloping algebra. Choose a basis &lt;math&gt;&lt;mo stretchy=&quot;false&quot;&gt;{&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;𝐱&lt;/mi&gt;&lt;mi&gt;𝑖&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;}&lt;/mo&gt;&lt;/math&gt; and denote the symmetric algebra by &lt;math&gt;&lt;mi&gt;𝘚&lt;/mi&gt;&lt;mo form=&quot;prefix&quot; stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;𝔤&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/math&gt;. Then the PBW theorem asserts the existence of a graded algebra isomorphism&lt;/p&gt;&lt;math display=&quot;block&quot;&gt;&lt;mi&gt;𝚐&lt;/mi&gt;&lt;mi&gt;𝚛&lt;/mi&gt;&lt;mspace width=&quot;0.1667em&quot;/&gt;&lt;mi&gt;𝒰︀&lt;/mi&gt;&lt;mo form=&quot;prefix&quot; stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;𝔤&lt;/mi&gt;&lt;mo form=&quot;postfix&quot; stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mspace width=&quot;0.2778em&quot;/&gt;&lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;≅&lt;/mo&gt;&lt;mspace width=&quot;0.2778em&quot;/&gt;&lt;mi&gt;𝘚&lt;/mi&gt;&lt;mo form=&quot;prefix&quot; stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;𝔤&lt;/mi&gt;&lt;mo form=&quot;postfix&quot; stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo rspace=&quot;0em&quot;&gt;,&lt;/mo&gt;&lt;/math&gt;&lt;p&gt;where &lt;math&gt;&lt;mi&gt;𝚐&lt;/mi&gt;&lt;mi&gt;𝚛&lt;/mi&gt;&lt;/math&gt; denotes the associated graded algebra with respect to the standard filtration. In the representation theory of Lie algebras, the adjoint action is often written as &lt;math&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;𝚊&lt;/mi&gt;&lt;mi&gt;𝚍&lt;/mi&gt;&lt;/mrow&gt;&lt;mi&gt;𝐱&lt;/mi&gt;&lt;/msub&gt;&lt;mo form=&quot;prefix&quot; stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;𝔶&lt;/mi&gt;&lt;mo form=&quot;postfix&quot; stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo form=&quot;prefix&quot; stretchy=&quot;false&quot;&gt;[&lt;/mo&gt;&lt;mi&gt;𝐱&lt;/mi&gt;&lt;mo&gt;,&lt;/mo&gt;&lt;mi&gt;𝔶&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;]&lt;/mo&gt;&lt;/math&gt; (with &lt;math&gt;&lt;mi&gt;𝔶&lt;/mi&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;𝔤&lt;/mi&gt;&lt;/math&gt;). Usually the ground field is taken to be &lt;math&gt;&lt;mi&gt;ℂ&lt;/mi&gt;&lt;/math&gt; or &lt;math&gt;&lt;mi&gt;ℝ&lt;/mi&gt;&lt;/math&gt;, in which case &lt;math&gt;&lt;mi&gt;𝒰︀&lt;/mi&gt;&lt;mo form=&quot;prefix&quot; stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;𝔤&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/math&gt; has a natural Hopf algebra structure, and the left regular action is given by &lt;math&gt;&lt;msub&gt;&lt;mi&gt;𝘓&lt;/mi&gt;&lt;mi&gt;𝐱&lt;/mi&gt;&lt;/msub&gt;&lt;mo form=&quot;prefix&quot; stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;𝑢&lt;/mi&gt;&lt;mo form=&quot;postfix&quot; stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;𝐱&lt;/mi&gt;&lt;mi&gt;𝑢&lt;/mi&gt;&lt;/math&gt;. This result profoundly reveals the intrinsic connection between Lie algebras and associative algebras.&lt;/p&gt;&lt;/blockquote&gt;&lt;/article&gt;</content>
  </entry>
  <entry>
    <title>Profile a Parser Implementation in Rust</title>
    <id>https://blog.wybxc.cc/blog/profile-cgrammar/</id>
    <link href="https://blog.wybxc.cc/blog/profile-cgrammar/"/>
    <published>2026-01-14T00:00:00Z</published>
    <updated>2026-01-14T00:00:00Z</updated>
    <content type="html" xml:base="https://blog.wybxc.cc/blog/profile-cgrammar/">&lt;article&gt;&lt;aside class&gt;&lt;p&gt;Jan 14, 2026&lt;br&gt;7 mins read&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;&lt;nav role=&quot;doc-toc&quot;&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;div&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-1&quot;&gt;Profile a Parser Implementation in Rust&lt;/a&gt;&lt;/div&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-2&quot;&gt;Prepare the Benchmark&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-3&quot;&gt;Profile with &lt;code&gt;samply&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-4&quot;&gt;Understanding the Overhead&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-5&quot;&gt;Goodbye, Reference Counting&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-6&quot;&gt;The Lessons Learned&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/nav&gt;&lt;/aside&gt;&lt;h2 id=&quot;loc-1&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-1&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Profile a Parser Implementation in Rust&lt;/h2&gt;&lt;p&gt;In 2025, I developed &lt;a href=&quot;https://crates.io/crates/cgrammar&quot;&gt;cgrammar&lt;/a&gt;, a comprehensive ISO C23 grammar parser in Rust, leveraging the &lt;a href=&quot;https://crates.io/crates/chumsky&quot;&gt;chumsky&lt;/a&gt; parser combinator library. While originally designed for my internal projects, I open-sourced it as a general-purpose C parser. This library is distinguished by its isomorphic approach to C23 attributes. By exposing C syntax elements as reusable parser combinators, it allows for granular parsing of attribute contents consistent with the language’s core grammar.&lt;/p&gt;&lt;p&gt;When I created the parser, I deliberately set performance aside as a consideration to focus exclusively on robustness and the complexities of the C language. Later, however, I wanted to understand the parser’s runtime characteristics, so I decided to profile the library and share my findings in this blog post.&lt;/p&gt;&lt;p&gt;Here are the key takeaways:&lt;/p&gt;&lt;ol&gt;&lt;li value=&quot;1&quot;&gt;&lt;code&gt;Rc::clone&lt;/code&gt; is heavier than anticipated.&lt;/li&gt;&lt;li value=&quot;2&quot;&gt;Parser combinators are hard to profile due to their layered abstractions. However, optimizations outside the combinators can still result in significant performance gains.&lt;/li&gt;&lt;/ol&gt;&lt;h3 id=&quot;loc-2&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-2&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Prepare the Benchmark&lt;/h3&gt;&lt;p&gt;Profiling the parser required a large C codebase. Luckily, I already had a perfect candidate: the parser’s own test cases&lt;sup&gt;1&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;1.&lt;/span&gt;&lt;span&gt;I will give credits to the &lt;a href=&quot;https://github.com/thradams/cake&quot;&gt;cake&lt;/a&gt; project where the test cases are originally sourced from.&lt;/span&gt;&lt;/span&gt;. Once preprocessed, this resulted in about 1.2 million lines of C code (or 20k lines stripped of comments and whitespace).&lt;/p&gt;&lt;p&gt;The benchmark runner implementation was straightforward: simply iterate through a directory and parse the files one by one. I placed this logic in &lt;code&gt;benches/bench.rs&lt;/code&gt; and added the following configuration to &lt;code&gt;Cargo.toml&lt;/code&gt;. This setup ensures that Cargo uses the benchmark profile during execution, i.e., running in release mode with debug symbols. And I turned off the default benchmark harness to allow for my own main function.&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;toml&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;profile&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bench&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;debug&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;true&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;bench&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;]]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;name&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&quot;bench&quot;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;harness&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;loc-3&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-3&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Profile with &lt;code&gt;samply&lt;/code&gt;&lt;/h3&gt;&lt;p&gt;I choose the &lt;a href=&quot;https://github.com/mstange/samply/&quot;&gt;samply&lt;/a&gt; profiler, a general-purpose sampling profiler. It uses the Firefox profiler as its UI, which I find most user-friendly among the available options.&lt;/p&gt;&lt;p&gt;Running the profiler is as simple as prefixing the benchmark command with &lt;code&gt;samply record&lt;/code&gt;:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;hl-s1&quot;&gt;samply&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;record&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;cargo&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;bench&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After the benchmark completes, &lt;code&gt;samply&lt;/code&gt; will open the Firefox profiler UI in your default browser, displaying the collected profiling data, including call trees and flame graphs.&lt;/p&gt;&lt;div class=&quot;fullwidth&quot;&gt;&lt;img src=&quot;https://blog.wybxc.cc/_assets/1e54f0257fe9f639.png&quot; width=&quot;2484&quot; height=&quot;922&quot; style=&quot;display: block&quot;&gt;&lt;/div&gt;&lt;p&gt;As expected, the parsing logic dominated the execution time. However, drilling down proved difficult: most function calls appeared as generic &lt;code&gt;&amp;lt;chumsky::... as chumsky::Parser&amp;lt;I, O, E&gt;&gt;::go&gt;&lt;/code&gt; signatures, making it impossible to identify which specific combinators were the bottlenecks.&lt;/p&gt;&lt;p&gt;This is largely the price of abstraction. Once parser combinators are composed, their high-level structure is erased at runtime, preventing a non-invasive profiler like &lt;code&gt;samply&lt;/code&gt; from seeing through the layers.&lt;/p&gt;&lt;p&gt;I was nearly ready to give up on &lt;code&gt;samply&lt;/code&gt;, but I decided to inspect the call tree one last time. That’s when I noticed something odd: a massive amount of time, &lt;strong&gt;over 20%&lt;/strong&gt; of the total execution, was being consumed by &lt;code&gt;Cell::get&lt;/code&gt;, triggered primarily by &lt;code&gt;Rc::clone&lt;/code&gt; and &lt;code&gt;Rc::drop&lt;/code&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;2.&lt;/span&gt;&lt;span&gt;You may not find then in the previous screenshot because I had already optimized the code before taking it.&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;I was floored. I never expected &lt;code&gt;Rc&lt;/code&gt; operations to be such a heavy burden. So, what exactly was going on?&lt;/p&gt;&lt;h3 id=&quot;loc-4&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-4&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Understanding the Overhead&lt;/h3&gt;&lt;p&gt;A look at the call tree revealed the culprit: the extensive &lt;code&gt;Rc::clone&lt;/code&gt; and &lt;code&gt;Rc::drop&lt;/code&gt; calls were tied directly to state management in the lexer and parser.&lt;/p&gt;&lt;p&gt;To understand why, here is a bit of background on &lt;code&gt;cgrammar&lt;/code&gt;. The lexer consumes preprocessed C code, where the preprocessor inserts line directives to map back to the original source file. To report errors accurately, the lexer must track the current filename and line number, updating them whenever it encounters these directives. However, because the parser supports backtracking, the lexer needs to be able to snapshot and restore its state at any point. I implemented this using &lt;code&gt;chumsky&lt;/code&gt;’s stateful parsing features, specifically via the &lt;code&gt;Inspector&lt;/code&gt; trait and a custom &lt;code&gt;Checkpoint&lt;/code&gt; type, where &lt;code&gt;chumsky&lt;/code&gt; can save the current state into a &lt;code&gt;Checkpoint&lt;/code&gt; and restore it later as needed.&lt;/p&gt;&lt;p&gt;This is where &lt;code&gt;Rc&lt;/code&gt; entered the picture. Since the filename is part of the lexer state, I wrapped it in an &lt;code&gt;Rc&amp;lt;str&gt;&lt;/code&gt;. My logic was that deep-copying the string string data upon every backtrack would be prohibitively expensive. The use of &lt;code&gt;Rc&lt;/code&gt; makes the lexer state a cheap-to-clone type, and I simply use the state itself as the &lt;code&gt;Checkpoint&lt;/code&gt; type. While I was right about avoiding deep copies, I failed to anticipate that the state would be cloned so frequently that the reference counting overhead itself would become a bottleneck.&lt;/p&gt;&lt;p&gt;To confirm this suspicion, I instrumented the lexer to count the clones. The results were staggering: while parsing 1.2 million lines of C code, the lexer state was cloned over &lt;strong&gt;400 million&lt;/strong&gt; times.&lt;/p&gt;&lt;p&gt;It turns out &lt;strong&gt;&lt;code&gt;Rc&lt;/code&gt; itself isn’t slow&lt;/strong&gt;; the average &lt;code&gt;Rc::clone&lt;/code&gt; took about 6ns, which is typical for an L2 cache access. There were no major cache-miss penalties; the problem was simply that my design triggered an excessive volume of operations. The parser state, which tracks context-sensitive constructs like &lt;code&gt;typedef&lt;/code&gt;s, suffered from the same issue (albeit with about 20% of the clone volume).&lt;/p&gt;&lt;p&gt;The solution is clear: I need to eliminate &lt;code&gt;Rc&lt;/code&gt; from the state entirely. By redesigning the state, I can ensure that checkpoints are &lt;code&gt;Copy&lt;/code&gt; types, making save/restore operations trivial without any indirect memory access.&lt;/p&gt;&lt;h3 id=&quot;loc-5&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-5&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Goodbye, Reference Counting&lt;/h3&gt;&lt;p&gt;Since the lexer and parser states utilize different structures, I adopted two distinct strategies to eliminate &lt;code&gt;Rc&lt;/code&gt; overhead.&lt;/p&gt;&lt;p&gt;For the lexer, the only field utilizing &lt;code&gt;Rc&lt;/code&gt; was the filename. I decided to replace this with a “global string pool”. Well, to be honest, I simply &lt;em&gt;leak&lt;/em&gt; the filename strings to obtain a &lt;code&gt;&amp;amp;&apos;static str&lt;/code&gt;, which implements &lt;code&gt;Copy&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Don’t panic at the mention of memory leaks! If data is stored in a pool that persists for the entire program’s duration, it is effectively leaked memory anyway. Since the number of source files is practically bounded and small, this is an acceptable trade-off to completely bypass reference counting. &lt;sup&gt;3&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;3.&lt;/span&gt;&lt;span&gt;UPDATE: After some discussion &lt;a href=&quot;https://www.reddit.com/r/rust/comments/1qdeko7/i_profiled_my_parser_and_found_rcclone_to_be_the/&quot;&gt;on Reddit&lt;/a&gt;, I realized that it is better to use something like &lt;a href=&quot;https://crates.io/crates/yoke&quot;&gt;yoke&lt;/a&gt; to attach the source input to the parser’s output, making filenames simply references into the input data. This way, &lt;strong&gt;no memory is leaked&lt;/strong&gt; and no global state is needed.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;The parser state is much larger and more complex, so it can’t simply implement &lt;code&gt;Copy&lt;/code&gt;. Instead, I used a slab allocator to manage snapshots of the parser state.&lt;/p&gt;&lt;p&gt;The key insight here is that while the parser saves and restores state frequently, the number of unique state versions is relatively low (typically just hundreds per file). By storing the actual state data in a slab, checkpoints can be represented by simple integer indices, which are significantly cheaper than &lt;code&gt;Rc&lt;/code&gt; pointers. When I need to mutate the state, I clone it into a new slab entry to ensure previous checkpoints remain valid.&lt;/p&gt;&lt;p&gt;This design trades memory usage for performance, as I defer the cleanup of old states until parsing is complete. However, this isn’t a major issue; I can still use &lt;code&gt;Rc&lt;/code&gt; inside the state structure to share data between versions, and the resulting speed gain is well worth the extra memory footprint.&lt;/p&gt;&lt;p&gt;With these changes, I re-ran the benchmarks and saw a &lt;strong&gt;14% overall speedup&lt;/strong&gt;. That is massive, especially considering I didn’t touch the actual parsing logic at all.&lt;/p&gt;&lt;h3 id=&quot;loc-6&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/profile-cgrammar/#loc-6&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;The Lessons Learned&lt;/h3&gt;&lt;p&gt;In Rust, &lt;code&gt;Rc&lt;/code&gt; is often considered the representative of cheap cloning types, and previously I thought I could clone it liberally without giving performance a second thought. However, in this specific case, the sheer frequency of these clones turned out to be a major bottleneck.&lt;/p&gt;&lt;p&gt;The lesson here is: always consider the volume of operations, not just their individual cost. When you are dealing with millions of operations, the overhead from memory traffic (and even cache-hit access!) can accumulate into a significant performance penalty.&lt;/p&gt;&lt;p&gt;Wrestling with these &lt;code&gt;Rc&lt;/code&gt; issues actually sidetracked me from my original goal: finding an effective way to profile parser combinators. That is a rabbit hole for another day, perhaps I’ll do some proper research and dedicate a future blog post to it?&lt;/p&gt;&lt;/article&gt;</content>
  </entry>
  <entry>
    <title>Pretty Printer in Rustc</title>
    <id>https://blog.wybxc.cc/blog/pretty-printer-rustc/</id>
    <link href="https://blog.wybxc.cc/blog/pretty-printer-rustc/"/>
    <published>2024-07-28T00:00:00Z</published>
    <updated>2024-07-28T00:00:00Z</updated>
    <content type="html" xml:base="https://blog.wybxc.cc/blog/pretty-printer-rustc/">&lt;article&gt;&lt;aside class&gt;&lt;p&gt;Jul 28, 2024&lt;br&gt;5 mins read&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;&lt;nav role=&quot;doc-toc&quot;&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;div&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-1&quot;&gt;Pretty Printer in Rustc&lt;/a&gt;&lt;/div&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-2&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-3&quot;&gt;Oppen’s Pretty Printer&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-4&quot;&gt;Using the Pretty Printer&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-5&quot;&gt;Examples&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/nav&gt;&lt;/aside&gt;&lt;h2 id=&quot;loc-1&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-1&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Pretty Printer in Rustc&lt;/h2&gt;&lt;h3 id=&quot;loc-2&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-2&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Introduction&lt;/h3&gt;&lt;p&gt;Pretty printing is a programming technique used to format and display data structures, such as code, data, and configuration files, in a more readable and aesthetically pleasing way. This technique is especially useful during development, as it helps developers easily grasp the hierarchy and structure of code and data.&lt;/p&gt;&lt;p&gt;The main task of pretty printing involves managing line breaks and indentation. When data output is too lengthy to fit on a single line, pretty printing breaks it into multiple lines. It then determines the appropriate indentation for the subsequent lines, ensuring that the structure remains clear and easy to follow.&lt;/p&gt;&lt;p&gt;In this post, we’ll explore the pretty printing algorithm used in &lt;a href=&quot;https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_pretty/pp/index.html&quot;&gt;rustc&lt;/a&gt;, the Rust compiler, and utilized by the &lt;a href=&quot;https://crates.io/crates/prettyplease&quot;&gt;prettyplease&lt;/a&gt; crate. This approach is based on Derek C. Oppen’s paper, Pretty Printing&lt;sup&gt;1&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;1.&lt;/span&gt;&lt;span&gt;&lt;span role=&quot;doc-biblioref&quot;&gt;D. C. Oppen, “Prettyprinting,” &lt;em&gt;ACM Trans. Program. Lang. Syst.&lt;/em&gt;, vol. 2, no. 4, pp. 465–483, Oct. 1980, doi: &lt;a href=&quot;https://doi.org/10.1145/357114.357115&quot; target=&quot;_blank&quot;&gt;10.1145/357114.357115&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;. While Oppen’s pretty printer is less flexible than the widely used Wadler’s pretty printer&lt;sup&gt;2&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;2.&lt;/span&gt;&lt;span&gt;&lt;span role=&quot;doc-biblioref&quot;&gt;P. Wadler, “A Prettier Printer,” in &lt;em&gt;The Fun of Programming&lt;/em&gt;, J. Gibbons and O. De Moor, Eds., London: Macmillan Education UK, 2003, pp. 223–243. doi: &lt;a href=&quot;https://doi.org/10.1007/978-1-349-91518-7_11&quot; target=&quot;_blank&quot;&gt;10.1007/978-1-349-91518-7_11&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, it offers advantages in terms of speed and memory efficiency.&lt;/p&gt;&lt;h3 id=&quot;loc-3&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-3&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Oppen’s Pretty Printer&lt;/h3&gt;&lt;p&gt;Here’s a brief overview of the algorithm from the paper.&lt;/p&gt;&lt;p&gt;The algorithm reads from a token stream, consisting of:&lt;/p&gt;&lt;ol&gt;&lt;li value=&quot;1&quot;&gt;&lt;strong&gt;Words:&lt;/strong&gt; Plain strings printed as they are.&lt;/li&gt;&lt;li value=&quot;2&quot;&gt;&lt;strong&gt;Breakable Spaces:&lt;/strong&gt; Indicate potential line breaks. If no break occurs, these render as zero or more spaces.&lt;/li&gt;&lt;li value=&quot;3&quot;&gt;&lt;strong&gt;Delimiters:&lt;/strong&gt; Represented by &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt;, indicating the hierarchical structure of logically contiguous blocks.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Each token has an associated “size,” calculated as follows:&lt;/p&gt;&lt;ol&gt;&lt;li value=&quot;1&quot;&gt;The size of a string is its length.&lt;/li&gt;&lt;li value=&quot;2&quot;&gt;The size of a &lt;code&gt;]&lt;/code&gt; is 0&lt;sup&gt;3&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;3.&lt;/span&gt;&lt;span&gt;In the current implementation in rustc, the size of a &lt;code&gt;]&lt;/code&gt; is set to 1, which is technically incorrect but doesn’t affect the outcome since only the sign matters.&lt;/span&gt;&lt;/span&gt;.&lt;/li&gt;&lt;li value=&quot;3&quot;&gt;The size of a breakable space or a &lt;code&gt;[&lt;/code&gt; is determined by the total size from it (including its own space) to the next break point (or EOF)&lt;sup&gt;4&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;4.&lt;/span&gt;&lt;span&gt;According to the original paper, the size of a &lt;code&gt;]&lt;/code&gt; should be the total size of its delimited block. The size of a space should include its own length plus the size of the next block. The implementation in rustc differs from it… I don’t know why.&lt;/span&gt;&lt;/span&gt;. If there is an entire delimited block between them, that block is treated as a single unit. Inner breakable spaces within the block do not affect the size calculation for the outer elements.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;For example:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span&gt;&quot;fn&quot; &quot;foo&quot; _ &quot;(&quot; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;[&lt;/span&gt;&lt;span&gt; &quot;x&quot; &quot;:&quot; _ &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&quot;i32&quot;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;]&lt;/span&gt;&lt;span&gt; &quot;)&quot; &quot;-&gt;&quot; _ &quot;i32&quot; _ &quot;{&quot; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;[&lt;/span&gt;&lt;span&gt; &quot;return&quot; _ &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&quot;x&quot;&lt;/span&gt;&lt;span&gt; _ &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;]&lt;/span&gt;&lt;span&gt; &quot;}&quot;
 &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;2&lt;/span&gt;&lt;span&gt;     &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;3&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;11&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;1&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;2&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;1&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;1&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;11&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;3&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;0&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;1&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;2&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;4&lt;/span&gt;&lt;span&gt;   &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;3&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;12&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;1&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;6&lt;/span&gt;&lt;span&gt;     &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;6&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;2&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;1&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;2&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;0&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;1&lt;/span&gt;&lt;span&gt;
           |     |         |                  |       |     |          |     |
           |     +---------+                  +-------+     |          +-----+-------
           |               +------------------+       |     +----------+
           +----------------------------------+       +------------------------------&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To calculate the size, the algorithm uses a FIFO buffer to store “lookahead” information. During the “scan” process, tokens are added to the end of the buffer until there is enough information to calculate the size of the first element. Once the size is determined, the foremost elements are removed from the buffer and sent to the “print” process.&lt;/p&gt;&lt;p&gt;The “print” process is straightforward: it receives a token and its calculated size, then attempts to layout the token on the current line. If it encounters a breakable space and there’s not enough space remaining on the line, it breaks the line and indents the text, according to the extra information carried by the delimited and space tokens.&lt;/p&gt;&lt;p&gt;A key optimization in the algorithm is that once the size of a &lt;code&gt;[&lt;/code&gt; exceeds the remaining space on the line, it will never fit. Thus, its size can be set to infinity, and it can be quickly removed from the buffer. This ensures the buffer never holds more than &lt;math&gt;&lt;mi&gt;𝑂&lt;/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;/mo&gt;&lt;mi&gt;𝑚&lt;/mi&gt;&lt;mo&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/math&gt; elements, where &lt;math&gt;&lt;mi&gt;𝑚&lt;/mi&gt;&lt;/math&gt; is the line width.&lt;/p&gt;&lt;h3 id=&quot;loc-4&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-4&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Using the Pretty Printer&lt;/h3&gt;&lt;p&gt;The implementation of the pretty printer is found in the &lt;a href=&quot;https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_pretty/pp/index.html&quot;&gt;rustc_ast_pretty&lt;/a&gt; crate. The interface looks like this:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s3&quot;&gt;trait&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Printer&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;scan_string&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Cow&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;scan_begin&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;token&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;BeginToken&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;scan_end&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;scan_break&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;token&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;BreakToken&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;eof&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This corresponds directly with the algorithm: create a printer, invoke the &lt;code&gt;scan_*&lt;/code&gt; methods to feed tokens into it, and finally call &lt;code&gt;eof&lt;/code&gt; to get the result.&lt;/p&gt;&lt;p&gt;However, the &lt;code&gt;scan_*&lt;/code&gt; methods are private in rustc’s implementation. Instead, a higher-level facade is provided:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s3&quot;&gt;trait&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Printer&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Into&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Cow&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;wrd&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;ibox&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;indent&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;isize&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;cbox&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;indent&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;isize&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;visual_align&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;break_offset&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;off&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;isize&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;space&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;zerobreak&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;hardbreak&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;eof&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;-&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The &lt;code&gt;word&lt;/code&gt; method is equivalent to &lt;code&gt;scan_string&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;&lt;code&gt;ibox&lt;/code&gt;, &lt;code&gt;cbox&lt;/code&gt;, and &lt;code&gt;visual_align&lt;/code&gt; are specialized versions of &lt;code&gt;scan_begin&lt;/code&gt;, introducing different behaviors when a block breaks.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Consistent Breaking:&lt;/strong&gt; After the first break, no attempt is made to fit subsequent breaks on the same line.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Inconsistent Breaking:&lt;/strong&gt; Subsequent breaks may be fit together on the same line.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Visual Aligning:&lt;/strong&gt; A variant of consistent breaking where content is aligned at the same indentation.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;For example,&lt;/p&gt;&lt;pre&gt;&lt;code&gt;foo(hello, there, good, friends)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;breaking inconsistently to become&lt;/p&gt;&lt;pre&gt;&lt;code&gt;foo(hello, there,
  good, friends);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;whereas a consistent breaking would yield:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;foo(hello,
  there,
  good,
  friends);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And the result of visual aligning is:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;foo(hello,
    there,
    good,
    friends);&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The &lt;code&gt;end&lt;/code&gt; method matches &lt;code&gt;scan_end&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;The &lt;code&gt;break_offset&lt;/code&gt; function internally calls &lt;code&gt;scan_break&lt;/code&gt;, creating a breakable space with a specified width and indentation offset. The functions &lt;code&gt;space&lt;/code&gt;, &lt;code&gt;zerobreak&lt;/code&gt;, and &lt;code&gt;hardbreak&lt;/code&gt; are shorthand for specific &lt;code&gt;break_offset&lt;/code&gt; behaviors.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;space&lt;/code&gt; is a shortcut for &lt;code&gt;break_offset(1, 0)&lt;/code&gt;, which renders a single breakable space.&lt;/li&gt;&lt;li&gt;&lt;code&gt;zerobreak&lt;/code&gt; is equivalent to &lt;code&gt;break_offset(0, 0)&lt;/code&gt;, which renders nothing but creates a breakable point.&lt;/li&gt;&lt;li&gt;&lt;code&gt;hardbreak&lt;/code&gt; corresponds to &lt;code&gt;break_offset(INFINITY, 0)&lt;/code&gt;, which cannot fit within a line and thus always forces a line break.&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;loc-5&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/pretty-printer-rustc/#loc-5&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Examples&lt;/h3&gt;&lt;p&gt;The &lt;code&gt;cbox_delim&lt;/code&gt; function demonstrates an idiomatic use of the pretty printer: creating a &lt;code&gt;cbox&lt;/code&gt; and wrapping it with delimiters, useful for laying out code blocks with several statements.&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;cbox_delim&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Printer&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;indent&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;isize&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;delim&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;op&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;FnOnce&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Printer&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;delim&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;break_offset&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;indent&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;cbox&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;indent&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;op&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;break_offset&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;indent&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;

    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;delim&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;fn&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;separated&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Printer&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;sep&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;op&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;impl&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;FnMut&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;mut&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Printer&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;let&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;split_first&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;op&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;for&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;elt&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;in&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;rest&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;{&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;sep&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;space&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
            &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;op&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;elt&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;}&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;}&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;cbox_delim&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;INDENT&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&quot;{&quot;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&quot;}&quot;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;separated&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;&quot;;&quot;&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;statements&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;stmt&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;|&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;{&lt;/span&gt;&lt;span&gt;
       &lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;print_stmt&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;pp&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;stmt&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;More examples can be found in my &lt;a href=&quot;https://github.com/Wybxc/rustc_codegen_c/blob/master/crates/rustc_codegen_c_ast/src/pretty.rs&quot;&gt;rustc_codegen_c&lt;/a&gt; project.&lt;/p&gt;&lt;section role=&quot;doc-bibliography&quot;&gt;&lt;ul style=&quot;list-style-type: none&quot;&gt;&lt;li id=&quot;loc-6&quot;&gt;D. C. Oppen, “Prettyprinting,” &lt;em&gt;ACM Trans. Program. Lang. Syst.&lt;/em&gt;, vol. 2, no. 4, pp. 465–483, Oct. 1980, doi: &lt;a href=&quot;https://doi.org/10.1145/357114.357115&quot;&gt;10.1145/357114.357115&lt;/a&gt;.&lt;/li&gt;&lt;li id=&quot;loc-7&quot;&gt;P. Wadler, “A Prettier Printer,” in &lt;em&gt;The Fun of Programming&lt;/em&gt;, J. Gibbons and O. De Moor, Eds., London: Macmillan Education UK, 2003, pp. 223–243. doi: &lt;a href=&quot;https://doi.org/10.1007/978-1-349-91518-7_11&quot;&gt;10.1007/978-1-349-91518-7_11&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/section&gt;&lt;/article&gt;</content>
  </entry>
  <entry>
    <title>Rustc Codegen C</title>
    <id>https://blog.wybxc.cc/blog/rustc-codegen-c/</id>
    <link href="https://blog.wybxc.cc/blog/rustc-codegen-c/"/>
    <published>2024-06-30T00:00:00Z</published>
    <updated>2024-06-30T00:00:00Z</updated>
    <content type="html" xml:base="https://blog.wybxc.cc/blog/rustc-codegen-c/">&lt;article&gt;&lt;aside class&gt;&lt;p&gt;Jun 30, 2024&lt;br&gt;5 mins read&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;&lt;nav role=&quot;doc-toc&quot;&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;div&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-1&quot;&gt;Rustc Codegen C&lt;/a&gt;&lt;/div&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-2&quot;&gt;Contents&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-3&quot;&gt;Data Layout&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-4&quot;&gt;Unwinding&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-5&quot;&gt;Undefined Behaivor&lt;/a&gt;&lt;/div&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-6&quot;&gt;Aliasing and type punning&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-7&quot;&gt;Out-of-bounds pointer arithmetic&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-8&quot;&gt;Some topics that may not become difficult&lt;/a&gt;&lt;/div&gt;&lt;ol style=&quot;list-style-type: none&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-9&quot;&gt;Integer overflow&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-10&quot;&gt;Drop check&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/nav&gt;&lt;/aside&gt;&lt;h2 id=&quot;loc-1&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-1&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Rustc Codegen C&lt;/h2&gt;&lt;p&gt;For OSPP 2024, I applied for and was accepted to participate in the project &lt;a href=&quot;https://blog.rust-lang.org/2024/05/07/OSPP-2024.html&quot;&gt;“C codegen backend for rustc”&lt;/a&gt;. This is an exciting opportunity for me to engage with a community-driven open-source project for the first time.&lt;/p&gt;&lt;p&gt;The project involves developing a “backend” for rustc that translates Rust MIR to C code. This aims to enhance platform compatibility and potentially speed up compilation for rapid prototype development. The original concept was discussed on &lt;a href=&quot;https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/rustc_codegen_c&quot;&gt;Zulip&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Before diving in, conducting a survey on the topic is essential. Rust has more advanced features than C, which can make translating Rust MIR to C code challenging. Here, I outline some potential difficulties as an early overview of the project.&lt;/p&gt;&lt;p&gt;This blog post is basically an expanded version on my OSPP application, including details I initially missed.&lt;/p&gt;&lt;h3 id=&quot;loc-2&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-2&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Contents&lt;/h3&gt;&lt;h3 id=&quot;loc-3&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-3&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Data Layout&lt;/h3&gt;&lt;p&gt;Rust offers more complex data structures compared to C. Its &lt;a href=&quot;https://doc.rust-lang.org/nomicon/repr-rust.html&quot;&gt;default memory model&lt;/a&gt;, &lt;code&gt;#[repr(Rust)]&lt;/code&gt;, provides no stability guarantees, allowing Rust to optimize memory usage by rearranging fields for better efficiency.&lt;/p&gt;&lt;p&gt;Rust also has &lt;code&gt;#[repr(C)]&lt;/code&gt;, which mirrors C’s layout rules. Since Rust’s default layout is unspecified, we can use &lt;code&gt;#[repr(C)]&lt;/code&gt; for everything, which might fit our needs for the C codegen backend.&lt;/p&gt;&lt;p&gt;However, &lt;code&gt;#[repr(C)]&lt;/code&gt; isn’t exactly the same as directly translating to C structures. For example, Rust has Zero Sized Types (ZSTs), which have no equivalent in C since every C type must have a minimum size of 1.&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ZeroSizedType&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;repr&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;C&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;]&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Example&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;field1&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;u32&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;zst&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ZeroSizedType&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;// The size of `Example` is 4 bytes in Rust&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ZeroSizedType&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;

&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;Example&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;int&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;field1&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s1&quot;&gt;ZeroSizedType&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;zst&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s5&quot;&gt;// The size of `Example` is 8 bytes in C&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Another issue is niche optimization. In Rust, &lt;code&gt;Option&amp;lt;Box&amp;lt;T&gt;&gt;&lt;/code&gt; has the same size as &lt;code&gt;Box&amp;lt;T&gt;&lt;/code&gt; by using the null pointer “niche” to represent &lt;code&gt;None&lt;/code&gt;. This optimization isn’t straightforward to implement in C&lt;sup&gt;1&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;1.&lt;/span&gt;&lt;span&gt;Is niche optimization a MUST in Rust? As far as I know, there’s no formal specification on this. However, according to &lt;a href=&quot;https://github.com/rust-lang/rust/pull/60300&quot;&gt;this PR&lt;/a&gt;, niche-optimized values are considered FFI-safe, and many crates rely on this feature. Ignoring it would likely be problematic.&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;&lt;h3 id=&quot;loc-4&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-4&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Unwinding&lt;/h3&gt;&lt;p&gt;When a panic occurs in Rust, the program may unwind the stack to report errors and perform cleanup. A related concept in C is the &lt;code&gt;setjmp&lt;/code&gt; and &lt;code&gt;longjmp&lt;/code&gt; functions, which pass through the calling stack and are often used to implement execption mechanism.&lt;/p&gt;&lt;p&gt;When a program panics, capturing a backtrace for debugging is a common practice. However, implementing this in a C backend is challenging due to platform-specific differences in calling stack structures.&lt;/p&gt;&lt;p&gt;Of course there is a simple option to exit: use &lt;code&gt;panic=abort&lt;/code&gt;. This approach avoids unwinding by immediately terminating the program without performing any cleanup or backtrace. This method can be a practical choice during the early stages of development.&lt;/p&gt;&lt;h3 id=&quot;loc-5&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-5&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Undefined Behaivor&lt;/h3&gt;&lt;p&gt;The domain of undefined behavior &lt;a href=&quot;https://www.youtube.com/watch?v=DG-VLezRkYQ&quot;&gt;differs between Rust and C&lt;/a&gt;. There are instances where Rust code is well-defined but may lead to undefined behavior in C, and vice versa. The C codegen backend must ensure that the generated C code is free from undefined behavior.&lt;/p&gt;&lt;h4 id=&quot;loc-6&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-6&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Aliasing and type punning&lt;/h4&gt;&lt;p&gt;Strict aliasing rules in C can lead to various undefined behaviors when type punning is involved. Casting a pointer to a different type and accessing memory through the new type can cause issues.&lt;/p&gt;&lt;p&gt;It’s interesting that aliasing rules in Rust is less strict than C. The key rule in Rust is to coexist harmoniously with the borrow checker: a mutable reference must never be aliased by other pointers or references. Rust allows type punning as long as the data layouts of the source and destination types are guaranteed to match.&lt;/p&gt;&lt;p&gt;The C codegen backend must ensure that all type punning is handled correctly to avoid undefined behavior. This can be achieved by using unions or &lt;code&gt;memcpy&lt;/code&gt; to safely copy memory between different types.&lt;/p&gt;&lt;h4 id=&quot;loc-7&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-7&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Out-of-bounds pointer arithmetic&lt;/h4&gt;&lt;p&gt;Storing an invalid pointer in C results in undefined behavior. This occurs because, on certain platforms, pointers are stored in special registers, leading to potential CPU malfunctions. The only exception is a pointer just one position past an array, which can be used to indicate the end of a dynamic array, even though it may point to an invalid memory location.&lt;/p&gt;&lt;p&gt;In Rust, you can perform arbitrary arithmetic on pointers and freely create invalid pointers, provided you do not dereference them. However, Rust does not allow references to invalid pointees, adhering to the same requirements as C pointers. Therefore, Rust references can be considered analogous to real C pointers, while Rust pointers can be treated similarly to &lt;code&gt;size_t&lt;/code&gt; in C.&lt;/p&gt;&lt;h3 id=&quot;loc-8&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-8&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Some topics that may not become difficult&lt;/h3&gt;&lt;p&gt;In this part I will discuss some topics that I used to think it difficult, but actually not that hard to handle.&lt;/p&gt;&lt;h4 id=&quot;loc-9&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-9&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Integer overflow&lt;/h4&gt;&lt;p&gt;Signed integer overflow is undefined behavior in C. Therefore, the C code generation backend must properly handle integer overflow cases to avoid this undefined behavior.&lt;/p&gt;&lt;p&gt;However, Rust MIR explicitly marks out safe integer operations. These operations can be implemented by calling specific functions&lt;sup&gt;2&lt;/sup&gt;&lt;span role=&quot;note&quot; class=&quot;numbering note&quot;&gt;&lt;span class=&quot;number&quot;&gt;2.&lt;/span&gt;&lt;span&gt;The result type might be better defined as &lt;code&gt;struct { int err; int result; }&lt;/code&gt;, which simulates &lt;code&gt;Option&amp;lt;i32&gt;&lt;/code&gt; in Rust.&lt;/span&gt;&lt;/span&gt;, such as:&lt;/p&gt;&lt;pre&gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;hl-s0&quot;&gt;int&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s3&quot;&gt;checked_add&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;int&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;int&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;,&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;int&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;b&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;a&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;INT_MAX&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;err&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;INT_MAX&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;if&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;b&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;a&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;INT_MIN&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;-&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;)&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;err&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;INT_MIN&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;else&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;{&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;err&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
        &lt;/span&gt;&lt;span class=&quot;hl-s0&quot;&gt;return&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;a&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s4&quot;&gt;+&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;;&lt;/span&gt;&lt;span&gt;
    &lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;span&gt;
&lt;/span&gt;&lt;span class=&quot;hl-s2&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;loc-10&quot;&gt;&lt;span class=&quot;heading-anchor&quot;&gt;&lt;a href=&quot;https://blog.wybxc.cc/blog/rustc-codegen-c/#loc-10&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;g fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Link to this section&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Drop check&lt;/h4&gt;&lt;p&gt;Rust has an affine type system that automatically releases resources when they are no longer needed. Generally, the behavior of these automatic drops can be determined syntactically. However, there are instances where the drop behavior is more complex and requires additional runtime analysis.&lt;/p&gt;&lt;p&gt;But drop checks are not needed to manage manually in code generation. This is because the analysis related to drop checking occurs before the MIR generation. Consequently, all necessary details about drop checks are explicitly handled in the MIR.&lt;/p&gt;&lt;/article&gt;</content>
  </entry>
</feed>