From a831a15c17b9e98faab3dd98677131f9ce5b3afc Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 24 May 2021 00:28:20 +0100 Subject: [PATCH] accounts: Break out pct closure We're going to want to reuse it. Signed-off-by: Ian Jackson --- src/accounts.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/accounts.rs b/src/accounts.rs index fb6f17e2..9c12ca23 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -122,6 +122,13 @@ impl AccountScope { percent_encoding::NON_ALPHANUMERIC .remove(b'-'); + let pct = |n, f: &mut F| { + for frag in utf8_percent_encode(n, &ENCODE) { + f(frag)?; + } + Ok::<_,E>(()) + }; + match &self { AS::Server => { f("server")?; @@ -134,9 +141,7 @@ impl AccountScope { }; for n in ns { f(":")?; - for frag in utf8_percent_encode(n, &ENCODE) { - f(frag)?; - } + pct(n, &mut f)?; } } -- 2.30.2