aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-05-09 07:14:18 +0100
committerAkshay <[email protected]>2020-05-09 07:14:18 +0100
commit40cefb2ff08d0e872408c8218b5d4d22d2c5ba11 (patch)
treed812b655e814032f3a3d66dc2b03d1d291f588d8
parent89fe9e99ef25310412d8d92396a580069f18a67e (diff)
add missing syntax highlighting
-rw-r--r--docs/index.xml8
-rw-r--r--docs/posts/auto-currying_rust_functions/index.html6
-rw-r--r--posts/auto-currying_rust_functions.md2
3 files changed, 8 insertions, 8 deletions
diff --git a/docs/index.xml b/docs/index.xml
index 7a4d4e0..dce3d00 100644
--- a/docs/index.xml
+++ b/docs/index.xml
@@ -90,9 +90,9 @@ We have placed <code>?</code>s in place of return types. Let’s try to fix that
90A function cannot access it’s environment. Our solution will not work. <code>add_curried3</code> attempts to access <code>x</code>, which is not allowed! A closure<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a> however, can. If we are returning a closure, our return type must be <code>impl Fn</code>, and not <code>fn</code>. The difference between the <code>Fn</code> trait and function pointers is beyond the scope of this post.</p> 90A function cannot access it’s environment. Our solution will not work. <code>add_curried3</code> attempts to access <code>x</code>, which is not allowed! A closure<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a> however, can. If we are returning a closure, our return type must be <code>impl Fn</code>, and not <code>fn</code>. The difference between the <code>Fn</code> trait and function pointers is beyond the scope of this post.</p>
91<h3 id="refinement">Refinement</h3> 91<h3 id="refinement">Refinement</h3>
92<p>Armed with knowledge, we refine our expected output, this time, employing closures:</p> 92<p>Armed with knowledge, we refine our expected output, this time, employing closures:</p>
93<pre><code>fn add(x: u32) -&gt; impl Fn(u32) -&gt; impl Fn(u32) -&gt; u32 { 93<div class="sourceCode" id="cb8"><pre class="sourceCode rust"><code class="sourceCode rust"><span id="cb8-1"><a href="#cb8-1"></a><span class="kw">fn</span> add(x<span class="op">:</span> <span class="dt">u32</span>) <span class="op">-&gt;</span> <span class="kw">impl</span> <span class="bu">Fn</span>(<span class="dt">u32</span>) <span class="op">-&gt;</span> <span class="kw">impl</span> <span class="bu">Fn</span>(<span class="dt">u32</span>) <span class="op">-&gt;</span> <span class="dt">u32</span> <span class="op">{</span></span>
94 return move |y| move |z| x + y + z; 94<span id="cb8-2"><a href="#cb8-2"></a> <span class="kw">return</span> <span class="kw">move</span> <span class="op">|</span>y<span class="op">|</span> <span class="kw">move</span> <span class="op">|</span>z<span class="op">|</span> x <span class="op">+</span> y <span class="op">+</span> z<span class="op">;</span></span>
95}</code></pre> 95<span id="cb8-3"><a href="#cb8-3"></a><span class="op">}</span></span></code></pre></div>
96<p>Alas, that does not compile either! It errors out with the following message:</p> 96<p>Alas, that does not compile either! It errors out with the following message:</p>
97<pre><code>error[E0562]: `impl Trait` not allowed outside of function 97<pre><code>error[E0562]: `impl Trait` not allowed outside of function
98and inherent method return types 98and inherent method return types
@@ -500,7 +500,7 @@ test tests::works ... ok</code></pre>
500</ol> 500</ol>
501</section></description> 501</section></description>
502<link>https://peppe.rs/posts/auto-currying_rust_functions/</link> 502<link>https://peppe.rs/posts/auto-currying_rust_functions/</link>
503<pubDate>Sat, 09 May 2020 06:07:00 +0000</pubDate> 503<pubDate>Sat, 09 May 2020 06:12:00 +0000</pubDate>
504<guid>https://peppe.rs/posts/auto-currying_rust_functions/</guid> 504<guid>https://peppe.rs/posts/auto-currying_rust_functions/</guid>
505</item> 505</item>
506<item> 506<item>
diff --git a/docs/posts/auto-currying_rust_functions/index.html b/docs/posts/auto-currying_rust_functions/index.html
index a8b7055..2ed5419 100644
--- a/docs/posts/auto-currying_rust_functions/index.html
+++ b/docs/posts/auto-currying_rust_functions/index.html
@@ -115,9 +115,9 @@ We have placed <code>?</code>s in place of return types. Let’s try to fix that
115A function cannot access it’s environment. Our solution will not work. <code>add_curried3</code> attempts to access <code>x</code>, which is not allowed! A closure<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a> however, can. If we are returning a closure, our return type must be <code>impl Fn</code>, and not <code>fn</code>. The difference between the <code>Fn</code> trait and function pointers is beyond the scope of this post.</p> 115A function cannot access it’s environment. Our solution will not work. <code>add_curried3</code> attempts to access <code>x</code>, which is not allowed! A closure<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a> however, can. If we are returning a closure, our return type must be <code>impl Fn</code>, and not <code>fn</code>. The difference between the <code>Fn</code> trait and function pointers is beyond the scope of this post.</p>
116<h3 id="refinement">Refinement</h3> 116<h3 id="refinement">Refinement</h3>
117<p>Armed with knowledge, we refine our expected output, this time, employing closures:</p> 117<p>Armed with knowledge, we refine our expected output, this time, employing closures:</p>
118<pre><code>fn add(x: u32) -&gt; impl Fn(u32) -&gt; impl Fn(u32) -&gt; u32 { 118<div class="sourceCode" id="cb8"><pre class="sourceCode rust"><code class="sourceCode rust"><span id="cb8-1"><a href="#cb8-1"></a><span class="kw">fn</span> add(x<span class="op">:</span> <span class="dt">u32</span>) <span class="op">-&gt;</span> <span class="kw">impl</span> <span class="bu">Fn</span>(<span class="dt">u32</span>) <span class="op">-&gt;</span> <span class="kw">impl</span> <span class="bu">Fn</span>(<span class="dt">u32</span>) <span class="op">-&gt;</span> <span class="dt">u32</span> <span class="op">{</span></span>
119 return move |y| move |z| x + y + z; 119<span id="cb8-2"><a href="#cb8-2"></a> <span class="kw">return</span> <span class="kw">move</span> <span class="op">|</span>y<span class="op">|</span> <span class="kw">move</span> <span class="op">|</span>z<span class="op">|</span> x <span class="op">+</span> y <span class="op">+</span> z<span class="op">;</span></span>
120}</code></pre> 120<span id="cb8-3"><a href="#cb8-3"></a><span class="op">}</span></span></code></pre></div>
121<p>Alas, that does not compile either! It errors out with the following message:</p> 121<p>Alas, that does not compile either! It errors out with the following message:</p>
122<pre><code>error[E0562]: `impl Trait` not allowed outside of function 122<pre><code>error[E0562]: `impl Trait` not allowed outside of function
123and inherent method return types 123and inherent method return types
diff --git a/posts/auto-currying_rust_functions.md b/posts/auto-currying_rust_functions.md
index 170fd31..8f60216 100644
--- a/posts/auto-currying_rust_functions.md
+++ b/posts/auto-currying_rust_functions.md
@@ -150,7 +150,7 @@ function pointers is beyond the scope of this post.
150Armed with knowledge, we refine our expected output, this 150Armed with knowledge, we refine our expected output, this
151time, employing closures: 151time, employing closures:
152 152
153``` 153```rust
154fn add(x: u32) -> impl Fn(u32) -> impl Fn(u32) -> u32 { 154fn add(x: u32) -> impl Fn(u32) -> impl Fn(u32) -> u32 {
155 return move |y| move |z| x + y + z; 155 return move |y| move |z| x + y + z;
156} 156}