mirror of
https://github.com/openharmony/third_party_rust_os_str_bytes.git
synced 2026-07-21 04:25:22 -04:00
39 lines
815 B
Rust
39 lines
815 B
Rust
use std::fmt;
|
|
use std::fmt::Formatter;
|
|
|
|
#[inline(always)]
|
|
pub(crate) const fn is_continuation(_: u8) -> bool {
|
|
false
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn decode_code_point(_: &[u8]) -> u32 {
|
|
unreachable!();
|
|
}
|
|
|
|
pub(crate) fn ends_with(string: &[u8], suffix: &[u8]) -> bool {
|
|
string.ends_with(suffix)
|
|
}
|
|
|
|
pub(crate) fn starts_with(string: &[u8], prefix: &[u8]) -> bool {
|
|
string.starts_with(prefix)
|
|
}
|
|
|
|
pub(crate) fn debug(string: &[u8], f: &mut Formatter<'_>) -> fmt::Result {
|
|
for byte in string {
|
|
write!(f, "\\x{:02X}", byte)?;
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(feature = "uniquote")]
|
|
pub(crate) mod uniquote {
|
|
use uniquote::Formatter;
|
|
use uniquote::Quote;
|
|
use uniquote::Result;
|
|
|
|
pub(crate) fn escape(string: &[u8], f: &mut Formatter<'_>) -> Result {
|
|
string.escape(f)
|
|
}
|
|
}
|