From 8d3a7fbc3f5e5fa7e13b902d457a610ab19a2fb9 Mon Sep 17 00:00:00 2001 From: Alvar Hansen Date: Mon, 4 Dec 2023 11:05:24 +0200 Subject: [PATCH] Improve ParsePrint example in Readme Current example is bit misleading as it results on non compiling code. With this change, we also showcase usage of preexisting Conversion. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 784a90ef52..b20f85e9e9 100644 --- a/README.md +++ b/README.md @@ -252,14 +252,15 @@ README Example.Ad hoc 8029.000 ns ± 44.44 % 163719 README Example.Scanner 19786.000 ns ± 35.26 % 62125 ``` -We can take things even further. With one small change we can turn the parser into a _printer_. +We can take things even further. With small change we can turn the parser into a _printer_. ```diff -let user = Parse(User.init(id:name:isAdmin:)) { +let user = ParsePrint(.memberwise(User.init(id:name:isAdmin:))) { Int.parser() "," - Prefix { $0 != "," }.map(String.init) +- Prefix { $0 != "," }.map(String.init) ++ Prefix { $0 != "," }.map(.string) "," Bool.parser() }