From 0a6edd2e6c1cd386f8d3aa8f01986edd77404942 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Tekuri Date: Mon, 1 Apr 2024 11:23:24 +0530 Subject: [PATCH] refactor: simplify --- src/util.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/util.rs b/src/util.rs index b5ec937..643628c 100644 --- a/src/util.rs +++ b/src/util.rs @@ -29,22 +29,22 @@ impl JsonPointer { } } - pub(crate) fn unescape(mut token: &str) -> Result, ()> { - let Some(mut tilde) = token.find('~') else { - return Ok(Cow::Borrowed(token)); + pub(crate) fn unescape(mut tok: &str) -> Result, ()> { + let Some(mut tilde) = tok.find('~') else { + return Ok(Cow::Borrowed(tok)); }; - let mut s = String::with_capacity(token.len()); + let mut s = String::with_capacity(tok.len()); loop { - s.push_str(&token[..tilde]); - token = &token[tilde + 1..]; - match token.chars().next() { + s.push_str(&tok[..tilde]); + tok = &tok[tilde + 1..]; + match tok.chars().next() { Some('1') => s.push('/'), Some('0') => s.push('~'), _ => return Err(()), } - token = &token[1..]; - let Some(i) = token.find('~') else { - s.push_str(token); + tok = &tok[1..]; + let Some(i) = tok.find('~') else { + s.push_str(tok); break; }; tilde = i;