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/index.xml | 8 ++++---- docs/posts/auto-currying_rust_functions/index.html | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'docs') 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 ?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
@@ -500,7 +500,7 @@ test tests::works ... ok
https://peppe.rs/posts/auto-currying_rust_functions/ -Sat, 09 May 2020 06:07:00 +0000 +Sat, 09 May 2020 06:12:00 +0000 https://peppe.rs/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