From 40cefb2ff08d0e872408c8218b5d4d22d2c5ba11 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 9 May 2020 11:44:18 +0530 Subject: add missing syntax highlighting --- docs/posts/auto-currying_rust_functions/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/posts/auto-currying_rust_functions') 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 ?s in place of return types. Let’s try to fix that A function cannot access it’s environment. Our solution will not work. add_curried3 attempts to access x, which is not allowed! A closure1 however, can. If we are returning a closure, our return type must be impl Fn, and not fn. The difference between the Fn trait and function pointers is beyond the scope of this post.

Refinement

Armed with knowledge, we refine our expected output, this time, employing closures:

-
fn add(x: u32) -> impl Fn(u32) -> impl Fn(u32) -> u32 {
-  return move |y| move |z| x + y + z;
-}
+
fn add(x: u32) -> impl Fn(u32) -> impl Fn(u32) -> u32 {
+  return move |y| move |z| x + y + z;
+}

Alas, that does not compile either! It errors out with the following message:

error[E0562]: `impl Trait` not allowed outside of function
 and inherent method return types
-- 
cgit v1.2.3