diff rust/hg-core/src/config/layer.rs @ 46505:a25033eb43b5

rhg: add limited support for the `config` sub-command Only with one argument and no flag. This is mostly for testing. Differential Revision: https://phab.mercurial-scm.org/D9972
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 08 Feb 2021 23:41:58 +0100
parents 2e5dd18d6dc3
children 1f55cd5b292f
line wrap: on
line diff
--- a/rust/hg-core/src/config/layer.rs	Mon Feb 08 23:08:44 2021 +0100
+++ b/rust/hg-core/src/config/layer.rs	Mon Feb 08 23:41:58 2021 +0100
@@ -58,8 +58,8 @@
         fn parse_one(arg: &[u8]) -> Option<(Vec<u8>, Vec<u8>, Vec<u8>)> {
             use crate::utils::SliceExt;
 
-            let (section_and_item, value) = split_2(arg, b'=')?;
-            let (section, item) = split_2(section_and_item.trim(), b'.')?;
+            let (section_and_item, value) = arg.split_2(b'=')?;
+            let (section, item) = section_and_item.trim().split_2(b'.')?;
             Some((
                 section.to_owned(),
                 item.to_owned(),
@@ -67,13 +67,6 @@
             ))
         }
 
-        fn split_2(bytes: &[u8], separator: u8) -> Option<(&[u8], &[u8])> {
-            let mut iter = bytes.splitn(2, |&byte| byte == separator);
-            let a = iter.next()?;
-            let b = iter.next()?;
-            Some((a, b))
-        }
-
         let mut layer = Self::new(ConfigOrigin::CommandLine);
         for arg in cli_config_args {
             let arg = arg.as_ref();