pub fn string_script(s: &str) -> Result<(String, String), &'static str>
Expand description
Parser of strings in the form of “text1:text2”. Return a tuple of 2 strings: (“text1, “text2”).
use docker_pose::string_script;
assert_eq!(string_script("abc:def"), Ok(("abc".to_string(), "def".to_string())));
assert_eq!(string_script("abc:"), Ok(("abc".to_string(), "".to_string())));
assert_eq!(
string_script("abc:def:more after->:"),
Ok(("abc".to_string(), "def:more after->:".to_string()))
);
assert_eq!(string_script(""), Err("must be at least 2 characters long"));
assert_eq!(string_script("a"), Err("must be at least 2 characters long"));
assert_eq!(string_script("abc"), Err("separator symbol : not found in the expression"));
assert_eq!(string_script(":def"), Err("empty left expression"));