#[repr(C)]pub struct JavaCodePoint { /* private fields */ }
Implementations§
Source§impl JavaCodePoint
impl JavaCodePoint
pub const MAX: JavaCodePoint
pub const REPLACEMENT_CHARACTER: JavaCodePoint
Sourcepub const fn from_u32(i: u32) -> Option<JavaCodePoint>
pub const fn from_u32(i: u32) -> Option<JavaCodePoint>
See char::from_u32
let c = JavaCodePoint::from_u32(0x2764);
assert_eq!(Some(JavaCodePoint::from_char('❤')), c);
assert_eq!(None, JavaCodePoint::from_u32(0x110000));
Sourcepub const unsafe fn from_u32_unchecked(i: u32) -> JavaCodePoint
pub const unsafe fn from_u32_unchecked(i: u32) -> JavaCodePoint
§Safety
The argument must be within the valid Unicode code point range of 0 to 0x10FFFF inclusive. Surrogate code points are allowed.
Sourcepub const fn from_char(char: char) -> JavaCodePoint
pub const fn from_char(char: char) -> JavaCodePoint
Converts a char
to a code point.
Sourcepub const fn as_u32(self) -> u32
pub const fn as_u32(self) -> u32
Converts this code point to a u32
.
assert_eq!(65, JavaCodePoint::from_char('A').as_u32());
assert_eq!(0xd800, JavaCodePoint::from_u32(0xd800).unwrap().as_u32());
Sourcepub const fn as_char(self) -> Option<char>
pub const fn as_char(self) -> Option<char>
Converts this code point to a char
.
assert_eq!(Some('a'), JavaCodePoint::from_char('a').as_char());
assert_eq!(None, JavaCodePoint::from_u32(0xd800).unwrap().as_char());
Sourcepub unsafe fn as_char_unchecked(self) -> char
pub unsafe fn as_char_unchecked(self) -> char
§Safety
The caller must ensure that this code point is not a surrogate code point.
Sourcepub fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16]
pub fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16]
assert_eq!(
2,
JavaCodePoint::from_char('𝕊')
.encode_utf16(&mut [0; 2])
.len()
);
assert_eq!(
1,
JavaCodePoint::from_u32(0xd800)
.unwrap()
.encode_utf16(&mut [0; 2])
.len()
);
// Should panic
JavaCodePoint::from_char('𝕊').encode_utf16(&mut [0; 1]);
Sourcepub fn encode_semi_utf8(self, dst: &mut [u8]) -> &mut [u8] ⓘ
pub fn encode_semi_utf8(self, dst: &mut [u8]) -> &mut [u8] ⓘ
Encodes this JavaCodePoint
into semi UTF-8, that is, UTF-8 with
surrogate code points. See also char::encode_utf8.
assert_eq!(
2,
JavaCodePoint::from_char('ß')
.encode_semi_utf8(&mut [0; 4])
.len()
);
assert_eq!(
3,
JavaCodePoint::from_u32(0xd800)
.unwrap()
.encode_semi_utf8(&mut [0; 4])
.len()
);
// Should panic
JavaCodePoint::from_char('ß').encode_semi_utf8(&mut [0; 1]);
Sourcepub fn eq_ignore_ascii_case(&self, other: &JavaCodePoint) -> bool
pub fn eq_ignore_ascii_case(&self, other: &JavaCodePoint) -> bool
Sourcepub fn escape_debug(self) -> CharEscapeIter ⓘ
pub fn escape_debug(self) -> CharEscapeIter ⓘ
See char::escape_debug
.
assert_eq!(
"a",
JavaCodePoint::from_char('a').escape_debug().to_string()
);
assert_eq!(
"\\n",
JavaCodePoint::from_char('\n').escape_debug().to_string()
);
assert_eq!(
"\\u{d800}",
JavaCodePoint::from_u32(0xd800)
.unwrap()
.escape_debug()
.to_string()
);
Sourcepub fn escape_default(self) -> CharEscapeIter ⓘ
pub fn escape_default(self) -> CharEscapeIter ⓘ
See char::escape_default
.
assert_eq!(
"a",
JavaCodePoint::from_char('a').escape_default().to_string()
);
assert_eq!(
"\\n",
JavaCodePoint::from_char('\n').escape_default().to_string()
);
assert_eq!(
"\\u{d800}",
JavaCodePoint::from_u32(0xd800)
.unwrap()
.escape_default()
.to_string()
);
Sourcepub fn escape_unicode(self) -> CharEscapeIter ⓘ
pub fn escape_unicode(self) -> CharEscapeIter ⓘ
See char::escape_unicode
.
assert_eq!(
"\\u{2764}",
JavaCodePoint::from_char('❤').escape_unicode().to_string()
);
assert_eq!(
"\\u{d800}",
JavaCodePoint::from_u32(0xd800)
.unwrap()
.escape_unicode()
.to_string()
);
Sourcepub fn is_alphabetic(self) -> bool
pub fn is_alphabetic(self) -> bool
See char::is_alphabetic
.
Sourcepub fn is_alphanumeric(self) -> bool
pub fn is_alphanumeric(self) -> bool
Sourcepub fn is_ascii(self) -> bool
pub fn is_ascii(self) -> bool
See char::is_ascii
.
Sourcepub const fn is_ascii_alphabetic(self) -> bool
pub const fn is_ascii_alphabetic(self) -> bool
Sourcepub const fn is_ascii_alphanumeric(self) -> bool
pub const fn is_ascii_alphanumeric(self) -> bool
Sourcepub const fn is_ascii_control(self) -> bool
pub const fn is_ascii_control(self) -> bool
Sourcepub const fn is_ascii_digit(self) -> bool
pub const fn is_ascii_digit(self) -> bool
See char::is_ascii_digit
.
Sourcepub const fn is_ascii_graphic(self) -> bool
pub const fn is_ascii_graphic(self) -> bool
Sourcepub const fn is_ascii_hexdigit(self) -> bool
pub const fn is_ascii_hexdigit(self) -> bool
Sourcepub const fn is_ascii_lowercase(self) -> bool
pub const fn is_ascii_lowercase(self) -> bool
Sourcepub const fn is_ascii_octdigit(self) -> bool
pub const fn is_ascii_octdigit(self) -> bool
Sourcepub const fn is_ascii_punctuation(self) -> bool
pub const fn is_ascii_punctuation(self) -> bool
Sourcepub const fn is_ascii_uppercase(self) -> bool
pub const fn is_ascii_uppercase(self) -> bool
Sourcepub const fn is_ascii_whitespace(self) -> bool
pub const fn is_ascii_whitespace(self) -> bool
Sourcepub fn is_control(self) -> bool
pub fn is_control(self) -> bool
See char::is_control
.
Sourcepub fn is_digit(self, radix: u32) -> bool
pub fn is_digit(self, radix: u32) -> bool
See char::is_digit
.
Sourcepub fn is_lowercase(self) -> bool
pub fn is_lowercase(self) -> bool
See char::is_lowercase
.
Sourcepub fn is_numeric(self) -> bool
pub fn is_numeric(self) -> bool
See char::is_numeric
.
Sourcepub fn is_uppercase(self) -> bool
pub fn is_uppercase(self) -> bool
See char::is_uppercase
.
Sourcepub fn is_whitespace(self) -> bool
pub fn is_whitespace(self) -> bool
See char::is_whitespace
.
Sourcepub const fn len_utf16(self) -> usize
pub const fn len_utf16(self) -> usize
See char::len_utf16
. Surrogate code points return 1.
let n = JavaCodePoint::from_char('ß').len_utf16();
assert_eq!(n, 1);
let len = JavaCodePoint::from_char('💣').len_utf16();
assert_eq!(len, 2);
assert_eq!(1, JavaCodePoint::from_u32(0xd800).unwrap().len_utf16());
Sourcepub const fn len_utf8(self) -> usize
pub const fn len_utf8(self) -> usize
See char::len_utf8
. Surrogate code points return 3.
let len = JavaCodePoint::from_char('A').len_utf8();
assert_eq!(len, 1);
let len = JavaCodePoint::from_char('ß').len_utf8();
assert_eq!(len, 2);
let len = JavaCodePoint::from_char('ℝ').len_utf8();
assert_eq!(len, 3);
let len = JavaCodePoint::from_char('💣').len_utf8();
assert_eq!(len, 4);
let len = JavaCodePoint::from_u32(0xd800).unwrap().len_utf8();
assert_eq!(len, 3);
Sourcepub fn make_ascii_lowercase(&mut self)
pub fn make_ascii_lowercase(&mut self)
Sourcepub fn make_ascii_uppercase(&mut self)
pub fn make_ascii_uppercase(&mut self)
Sourcepub const fn to_ascii_lowercase(self) -> JavaCodePoint
pub const fn to_ascii_lowercase(self) -> JavaCodePoint
let ascii = JavaCodePoint::from_char('A');
let non_ascii = JavaCodePoint::from_char('❤');
assert_eq!('a', ascii.to_ascii_lowercase());
assert_eq!('❤', non_ascii.to_ascii_lowercase());
Sourcepub const fn to_ascii_uppercase(self) -> JavaCodePoint
pub const fn to_ascii_uppercase(self) -> JavaCodePoint
let ascii = JavaCodePoint::from_char('a');
let non_ascii = JavaCodePoint::from_char('❤');
assert_eq!('A', ascii.to_ascii_uppercase());
assert_eq!('❤', non_ascii.to_ascii_uppercase());
Sourcepub fn to_lowercase(self) -> ToLowercase
pub fn to_lowercase(self) -> ToLowercase
See char::to_lowercase
.
Sourcepub fn to_uppercase(self) -> ToUppercase
pub fn to_uppercase(self) -> ToUppercase
See char::to_uppercase
.
Trait Implementations§
Source§impl Clone for JavaCodePoint
impl Clone for JavaCodePoint
Source§fn clone(&self) -> JavaCodePoint
fn clone(&self) -> JavaCodePoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for JavaCodePoint
impl Debug for JavaCodePoint
Source§impl Default for JavaCodePoint
impl Default for JavaCodePoint
Source§impl Display for JavaCodePoint
impl Display for JavaCodePoint
Source§impl<'a> Extend<&'a JavaCodePoint> for JavaString
impl<'a> Extend<&'a JavaCodePoint> for JavaString
Source§fn extend<T: IntoIterator<Item = &'a JavaCodePoint>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = &'a JavaCodePoint>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl Extend<JavaCodePoint> for JavaString
impl Extend<JavaCodePoint> for JavaString
Source§fn extend<T: IntoIterator<Item = JavaCodePoint>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = JavaCodePoint>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)