1use std::fmt; 2use std::fmt::Formatter; 3use std::str; 4 5pub(crate) use crate::util::is_continuation; 6 7use super::Result; 8 9#[allow(dead_code)] 10#[path = "../common/raw.rs"] 11mod common_raw; 12pub(crate) use common_raw::ends_with; 13pub(crate) use common_raw::starts_with; 14#[cfg(feature = "uniquote")] 15pub(crate) use common_raw::uniquote; 16 17pub(crate) fn validate_bytes(string: &[u8]) -> Result<()> { 18 super::from_bytes(string).map(drop) 19} 20 21pub(crate) fn decode_code_point(string: &[u8]) -> u32 { 22 let string = expect_encoded!(str::from_utf8(string)); 23 let mut chars = string.chars(); 24 let ch = chars 25 .next() 26 .expect("cannot parse code point from empty string"); 27 assert_eq!(None, chars.next(), "multiple code points found"); 28 ch.into() 29} 30 31pub(crate) fn debug(string: &[u8], _: &mut Formatter<'_>) -> fmt::Result { 32 assert!(string.is_empty()); 33 Ok(()) 34} 35