本文簡要介紹rust語言中 u8.escape_ascii
的用法。
用法
pub fn escape_ascii(&self) -> EscapeDefault
返回生成 u8
的轉義版本的迭代器,將其視為 ASCII 字符。
該行為與 ascii::escape_default
相同。
例子
#![feature(inherent_ascii_escape)]
assert_eq!("0", b'0'.escape_ascii().to_string());
assert_eq!("\\t", b'\t'.escape_ascii().to_string());
assert_eq!("\\r", b'\r'.escape_ascii().to_string());
assert_eq!("\\n", b'\n'.escape_ascii().to_string());
assert_eq!("\\'", b'\''.escape_ascii().to_string());
assert_eq!("\\\"", b'"'.escape_ascii().to_string());
assert_eq!("\\\\", b'\\'.escape_ascii().to_string());
assert_eq!("\\x9d", b'\x9d'.escape_ascii().to_string());
相關用法
- Rust u8.eq_ignore_ascii_case用法及代碼示例
- Rust u8.rotate_left用法及代碼示例
- Rust u8.pow用法及代碼示例
- Rust u8.is_ascii_whitespace用法及代碼示例
- Rust u8.from_ne_bytes用法及代碼示例
- Rust u8.wrapping_shl用法及代碼示例
- Rust u8.wrapping_shr用法及代碼示例
- Rust u8.saturating_add用法及代碼示例
- Rust u8.overflowing_shr用法及代碼示例
- Rust u8.overflowing_shl用法及代碼示例
- Rust u8.wrapping_neg用法及代碼示例
- Rust u8.abs_diff用法及代碼示例
- Rust u8.to_ne_bytes用法及代碼示例
- Rust u8.saturating_pow用法及代碼示例
- Rust u8.to_be_bytes用法及代碼示例
- Rust u8.carrying_mul用法及代碼示例
- Rust u8.log10用法及代碼示例
- Rust u8.log用法及代碼示例
- Rust u8.checked_rem用法及代碼示例
- Rust u8.overflowing_div用法及代碼示例
- Rust u8.unstable_div_ceil用法及代碼示例
- Rust u8.to_le_bytes用法及代碼示例
- Rust u8.next_power_of_two用法及代碼示例
- Rust u8.wrapping_div用法及代碼示例
- Rust u8.overflowing_sub用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 u8.escape_ascii。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。