Struct java_string::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<'de> Deserialize<'de> for JavaCodePoint

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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 + PartialOrd,

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 Serialize for JavaCodePoint

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. 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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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§

default 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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,