Struct JavaCodePoint

Source
#[repr(C)]
pub struct JavaCodePoint { /* private fields */ }

Implementations§

Source§

impl JavaCodePoint

Source

pub const MAX: JavaCodePoint

Source

pub const REPLACEMENT_CHARACTER: JavaCodePoint

Source

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));
Source

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.

Source

pub const fn from_char(char: char) -> JavaCodePoint

Converts a char to a code point.

Source

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());
Source

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());
Source

pub unsafe fn as_char_unchecked(self) -> char

§Safety

The caller must ensure that this code point is not a surrogate code point.

Source

pub fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16]

See char::encode_utf16

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]);
Source

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]);
Source

pub fn eq_ignore_ascii_case(&self, other: &JavaCodePoint) -> bool

Source

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()
);
Source

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()
);
Source

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()
);
Source

pub fn is_alphabetic(self) -> bool

Source

pub fn is_alphanumeric(self) -> bool

Source

pub fn is_ascii(self) -> bool

Source

pub const fn is_ascii_alphabetic(self) -> bool

Source

pub const fn is_ascii_alphanumeric(self) -> bool

Source

pub const fn is_ascii_control(self) -> bool

Source

pub const fn is_ascii_digit(self) -> bool

Source

pub const fn is_ascii_graphic(self) -> bool

Source

pub const fn is_ascii_hexdigit(self) -> bool

Source

pub const fn is_ascii_lowercase(self) -> bool

Source

pub const fn is_ascii_octdigit(self) -> bool

Source

pub const fn is_ascii_punctuation(self) -> bool

Source

pub const fn is_ascii_uppercase(self) -> bool

Source

pub const fn is_ascii_whitespace(self) -> bool

Source

pub fn is_control(self) -> bool

Source

pub fn is_digit(self, radix: u32) -> bool

Source

pub fn is_lowercase(self) -> bool

Source

pub fn is_numeric(self) -> bool

Source

pub fn is_uppercase(self) -> bool

Source

pub fn is_whitespace(self) -> bool

Source

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());
Source

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);
Source

pub fn make_ascii_lowercase(&mut self)

Source

pub fn make_ascii_uppercase(&mut self)

Source

pub const fn to_ascii_lowercase(self) -> JavaCodePoint

See char::to_ascii_lowercase.


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());
Source

pub const fn to_ascii_uppercase(self) -> JavaCodePoint

See char::to_ascii_uppercase.


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());
Source

pub const fn to_digit(self, radix: u32) -> Option<u32>

Source

pub fn to_lowercase(self) -> ToLowercase

Source

pub fn to_uppercase(self) -> ToUppercase

Trait Implementations§

Source§

impl Clone for JavaCodePoint

Source§

fn clone(&self) -> JavaCodePoint

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JavaCodePoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for JavaCodePoint

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for JavaCodePoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Extend<&'a JavaCodePoint> for JavaString

Source§

fn extend<T: IntoIterator<Item = &'a JavaCodePoint>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<JavaCodePoint> for JavaString

Source§

fn extend<T: IntoIterator<Item = JavaCodePoint>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<JavaCodePoint> for JavaString

Source§

fn from(value: JavaCodePoint) -> Self

Converts to this type from the input type.
Source§

impl From<JavaCodePoint> for u32

Source§

fn from(value: JavaCodePoint) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for JavaCodePoint

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromIterator<&'a JavaCodePoint> for JavaString

Source§

fn from_iter<T: IntoIterator<Item = &'a JavaCodePoint>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<JavaCodePoint> for JavaString

Source§

fn from_iter<T: IntoIterator<Item = JavaCodePoint>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromStr for JavaCodePoint

Source§

type Err = ParseCharError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for JavaCodePoint

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JavaStrPattern for &JavaCodePoint

Source§

fn prefix_len_in(&mut self, haystack: &JavaStr) -> Option<usize>

Source§

fn suffix_len_in(&mut self, haystack: &JavaStr) -> Option<usize>

Source§

fn find_in(&mut self, haystack: &JavaStr) -> Option<(usize, usize)>

Source§

fn rfind_in(&mut self, haystack: &JavaStr) -> Option<(usize, usize)>

Source§

impl JavaStrPattern for JavaCodePoint

Source§

fn prefix_len_in(&mut self, haystack: &JavaStr) -> Option<usize>

Source§

fn suffix_len_in(&mut self, haystack: &JavaStr) -> Option<usize>

Source§

fn find_in(&mut self, haystack: &JavaStr) -> Option<(usize, usize)>

Source§

fn rfind_in(&mut self, haystack: &JavaStr) -> Option<(usize, usize)>

Source§

impl Ord for JavaCodePoint

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<JavaCodePoint> for char

Source§

fn eq(&self, other: &JavaCodePoint) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<char> for JavaCodePoint

Source§

fn eq(&self, other: &char) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for JavaCodePoint

Source§

fn eq(&self, other: &JavaCodePoint) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<JavaCodePoint> for char

Source§

fn partial_cmp(&self, other: &JavaCodePoint) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<char> for JavaCodePoint

Source§

fn partial_cmp(&self, other: &char) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for JavaCodePoint

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for JavaCodePoint

Source§

impl Eq for JavaCodePoint

Source§

impl StructuralPartialEq for JavaCodePoint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.