Struct java_string::JavaCodePoint
source · #[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<'de> Deserialize<'de> for JavaCodePoint
impl<'de> Deserialize<'de> for JavaCodePoint
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
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
)source§impl From<JavaCodePoint> for JavaString
impl From<JavaCodePoint> for JavaString
source§fn from(value: JavaCodePoint) -> Self
fn from(value: JavaCodePoint) -> Self
source§impl From<JavaCodePoint> for u32
impl From<JavaCodePoint> for u32
source§fn from(value: JavaCodePoint) -> Self
fn from(value: JavaCodePoint) -> Self
source§impl From<u8> for JavaCodePoint
impl From<u8> for JavaCodePoint
source§impl<'a> FromIterator<&'a JavaCodePoint> for JavaString
impl<'a> FromIterator<&'a JavaCodePoint> for JavaString
source§fn from_iter<T: IntoIterator<Item = &'a JavaCodePoint>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = &'a JavaCodePoint>>(iter: T) -> Self
source§impl FromIterator<JavaCodePoint> for JavaString
impl FromIterator<JavaCodePoint> for JavaString
source§fn from_iter<T: IntoIterator<Item = JavaCodePoint>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = JavaCodePoint>>(iter: T) -> Self
source§impl FromStr for JavaCodePoint
impl FromStr for JavaCodePoint
source§impl Hash for JavaCodePoint
impl Hash for JavaCodePoint
source§impl JavaStrPattern for &JavaCodePoint
impl JavaStrPattern for &JavaCodePoint
source§impl JavaStrPattern for JavaCodePoint
impl JavaStrPattern for JavaCodePoint
source§impl Ord for JavaCodePoint
impl Ord for JavaCodePoint
source§impl PartialEq<JavaCodePoint> for char
impl PartialEq<JavaCodePoint> for char
source§impl PartialEq<char> for JavaCodePoint
impl PartialEq<char> for JavaCodePoint
source§impl PartialEq for JavaCodePoint
impl PartialEq for JavaCodePoint
source§impl PartialOrd<JavaCodePoint> for char
impl PartialOrd<JavaCodePoint> for char
source§impl PartialOrd<char> for JavaCodePoint
impl PartialOrd<char> for JavaCodePoint
source§impl PartialOrd for JavaCodePoint
impl PartialOrd for JavaCodePoint
source§impl Serialize for JavaCodePoint
impl Serialize for JavaCodePoint
impl Copy for JavaCodePoint
impl Eq for JavaCodePoint
impl StructuralPartialEq for JavaCodePoint
Auto Trait Implementations§
impl Freeze for JavaCodePoint
impl RefUnwindSafe for JavaCodePoint
impl Send for JavaCodePoint
impl Sync for JavaCodePoint
impl Unpin for JavaCodePoint
impl UnwindSafe for JavaCodePoint
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)