#[must_use]
pub fn split_qname(qname: &str) -> (Option<&str>, &str) {
match qname.find(':') {
Some(pos) => (Some(&qname[..pos]), &qname[pos + 1..]),
None => (None, qname),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_split_qname_with_prefix() {
assert_eq!(split_qname("xml:lang"), (Some("xml"), "lang"));
}
#[test]
fn test_split_qname_without_prefix() {
assert_eq!(split_qname("div"), (None, "div"));
}
#[test]
fn test_split_qname_empty() {
assert_eq!(split_qname(""), (None, ""));
}
#[test]
fn test_split_qname_colon_at_start() {
assert_eq!(split_qname(":local"), (Some(""), "local"));
}
#[test]
fn test_split_qname_colon_at_end() {
assert_eq!(split_qname("prefix:"), (Some("prefix"), ""));
}
#[test]
fn test_split_qname_multiple_colons() {
assert_eq!(split_qname("a:b:c"), (Some("a"), "b:c"));
}
}