summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ozone/src/launcher/strsub.rs48
1 files changed, 0 insertions, 48 deletions
diff --git a/ozone/src/launcher/strsub.rs b/ozone/src/launcher/strsub.rs
index 307d0a1..3103816 100644
--- a/ozone/src/launcher/strsub.rs
+++ b/ozone/src/launcher/strsub.rs
@@ -21,54 +21,6 @@ where
}
}
-/* NOTE: the in-place implementation has been replaced for the following reasons:
- * - it was annoying to get lifetimes to work, so you could only either pass a trait implementation
- * or a closure
- * - it was probably slower than doing it out-of-place anyway, since you keep having to copy the
- * tail of the string for each replacement
- */
-
-// handles ${replacements} on this string IN-PLACE. Calls the "sub" function for each key it receives.
-// if "sub" returns None, it will use a default value or ignore the ${substitution}.
-// There are no "invalid inputs" and this function should never panic unless "sub" panics.
-/*pub fn replace_string(input: &mut String, sub: impl SubFunc) {
- let mut cursor = input.len();
- while let Some(idx) = input[..cursor].rfind(VAR_BEGIN) {
- // note: for some reason, apache processes escapes BEFORE checking if it's even a valid
- // replacement expression. strange behavior IMO.
- if let Some((pidx, ESCAPE)) = prev_char(input.as_ref(), idx) {
- // this "replacement" is escaped. remove the escape marker and continue.
- input.remove(pidx);
- cursor = pidx;
- continue;
- }
-
- let Some(endidx) = input[idx..cursor].find(VAR_END).map(|v| v + idx) else {
- // unclosed replacement expression. ignore.
- cursor = idx;
- continue;
- };
-
- let spec = &input[(idx + VAR_BEGIN.len())..endidx];
- let name;
- let def_opt;
-
- if let Some(def) = spec.find(VAR_DEFAULT) {
- name = &spec[..def];
- def_opt = Some(&spec[(def + VAR_DEFAULT.len())..]);
- } else {
- name = spec;
- def_opt = None;
- }
-
- if let Some(sub_val) = sub.substitute(name).map_or_else(|| def_opt.map(|d| Cow::Owned(d.to_owned())), |v| Some(v)) {
- input.replace_range(idx..(endidx + VAR_END.len()), sub_val.as_ref());
- }
-
- cursor = idx;
- }
-}*/
-
pub fn replace_string<'inp, 'rep>(input: &'inp str, sub: impl SubFunc<'inp, 'rep>) -> Cow<'inp, str> {
let mut ret: Option<String> = None;
let mut cursor = 0usize;