1 use std::fmt; 2 use std::fmt::Formatter; 3 use std::str; 4 5 pub(crate) use crate::util::is_continuation; 6 7 use super::Result; 8 9 #[allow(dead_code)] 10 #[path = "../common/raw.rs"] 11 mod common_raw; 12 pub(crate) use common_raw::ends_with; 13 pub(crate) use common_raw::starts_with; 14 #[cfg(feature = "uniquote")] 15 pub(crate) use common_raw::uniquote; 16 validate_bytes(string: &[u8]) -> Result<()>17pub(crate) fn validate_bytes(string: &[u8]) -> Result<()> { 18 super::from_bytes(string).map(drop) 19 } 20 decode_code_point(string: &[u8]) -> u3221pub(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 debug(string: &[u8], _: &mut Formatter<'_>) -> fmt::Result31pub(crate) fn debug(string: &[u8], _: &mut Formatter<'_>) -> fmt::Result { 32 assert!(string.is_empty()); 33 Ok(()) 34 } 35