Struct mut_str::Char

source ·
pub struct Char { /* private fields */ }
Expand description

A UTF-8 encoded character.

This type can only be obtained as a reference or mutable reference similarly to str.

use mut_str::Char;

let s = "Hello, World!";
let c = Char::get(s, 1).unwrap();

assert_eq!(c, 'e');

Implementations§

source§

impl Char

source

pub const unsafe fn new_unchecked(p: *const u8) -> *const Self

Create a new character reference from a pointer to a character.

§Safety

p must be a pointer to the first byte of a valid UTF-8 character.

source

pub const unsafe fn new_unchecked_mut(p: *mut u8) -> *mut Self

Create a new mutable character reference from a mutable pointer to a character.

§Safety

p must be a mutable pointer to the first byte of a valid UTF-8 character that can be mutated. String literals cannot be mutated.

source

pub fn get(s: &str, i: usize) -> Option<&Self>

Get a character reference from a str and an index.

use mut_str::Char;

let s = "Hello, World!";
let c = Char::get(s, 1).unwrap();

assert_eq!(c, 'e');
source

pub fn get_mut(s: &mut str, i: usize) -> Option<&mut Self>

Get a mutable character reference from a mutable str and an index.

use mut_str::Char;

let mut s = Box::<str>::from("Hello, World!");
let c = Char::get_mut(&mut *s, 1).unwrap();

assert_eq!(c, 'e');
source

pub fn len(&self) -> usize

Get the length of the character in bytes.

This will be in the range 1..=4.

use mut_str::Char;

let s = "oΦ⏣🌑";

assert_eq!(Char::get(s, 0).unwrap().len(), 1);
assert_eq!(Char::get(s, 1).unwrap().len(), 2);
assert_eq!(Char::get(s, 2).unwrap().len(), 3);
assert_eq!(Char::get(s, 3).unwrap().len(), 4);
Examples found in repository?
examples/iter.rs (line 8)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() {
    let mut s = Box::<str>::from("oφ⏣🌑");

    // Iterate over the characters printing their length and bytes
    s.ref_iter()
        .for_each(|c| println!("{c:?}\tlength: {}, bytes: {:?}", c.len(), c.as_bytes()));

    // Iterate over each character trying to make them uppercase
    // (Result::ok is being used to ignore the result)
    s.mut_iter().for_each(|c| {
        c.try_make_uppercase().ok();
    });

    println!("\n{s:?}");
}
source

pub const fn as_ptr(&self) -> *const u8

Get a pointer to the character (pointer).

source

pub fn as_mut_ptr(&mut self) -> *mut u8

Get a mutable pointer to the character (pointer).

source

pub fn as_bytes(&self) -> &[u8]

Get the character as a byte slice (slice).

use mut_str::Char;

let s = "Hello, 🌍!";

let c = Char::get(s, 1).unwrap();
assert_eq!(c.as_bytes(), &[101]);

let c = Char::get(s, 7).unwrap();
assert_eq!(c.as_bytes(), &[240, 159, 140, 141]);
Examples found in repository?
examples/iter.rs (line 8)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() {
    let mut s = Box::<str>::from("oφ⏣🌑");

    // Iterate over the characters printing their length and bytes
    s.ref_iter()
        .for_each(|c| println!("{c:?}\tlength: {}, bytes: {:?}", c.len(), c.as_bytes()));

    // Iterate over each character trying to make them uppercase
    // (Result::ok is being used to ignore the result)
    s.mut_iter().for_each(|c| {
        c.try_make_uppercase().ok();
    });

    println!("\n{s:?}");
}
source

pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8]

Get the character as a mutable byte slice (slice).

§Safety

See str::as_bytes_mut.

source

pub fn as_str(&self) -> &str

Get the character as a str.

use mut_str::Char;

let s = "Hello, 🌍!";

let c = Char::get(s, 1).unwrap();
assert_eq!(c.as_str(), "e");

let c = Char::get(s, 7).unwrap();
assert_eq!(c.as_str(), "🌍");
source

pub fn as_str_mut(&mut self) -> &mut str

Get the character as a mutable str.

use mut_str::Char;

let mut s = Box::<str>::from("Hello, 🌍!");

let c = Char::get_mut(&mut *s, 1).unwrap();
assert_eq!(c.as_str_mut(), "e");

let c = Char::get_mut(&mut *s, 7).unwrap();
assert_eq!(c.as_str_mut(), "🌍");
source

pub fn as_char(&self) -> char

Get the character as a char.

use mut_str::Char;

let s = "Hello, 🌍!";

let c = Char::get(s, 1).unwrap();
assert_eq!(c.as_char(), 'e');

let c = Char::get(s, 7).unwrap();
assert_eq!(c.as_char(), '🌍');
source

pub fn as_owned(&self) -> OwnedChar

Creates an OwnedChar from a borrowed Char.

use mut_str::{Char, OwnedChar};

let s = "Hello, 🌍!";

let c = Char::get(s, 1).unwrap();
assert_eq!(c.as_owned(), OwnedChar::from('e'));

let c = Char::get(s, 7).unwrap();
assert_eq!(c.as_owned(), OwnedChar::from('🌍'));
source

pub fn copy_to<'a>(&self, buffer: &'a mut [u8]) -> Option<&'a mut Self>

Copy the character to a byte buffer and get the str containing the inserted character. Returns None if buffer is shorter than self.

use mut_str::Char;

let s = "Hello, World!";
let c = Char::get(s, 1).unwrap();

let mut buffer = [0; 4];
let c2 = c.copy_to(&mut buffer).unwrap();

assert_eq!(c2, c);
source

pub fn replace<C>(&mut self, r: C) -> Result<(), LenNotEqual>
where C: Into<char>,

Replace the character with another of the same length.

use mut_str::Char;

let mut s = Box::<str>::from("oΦ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
assert!(c.replace('e').is_ok());
assert_eq!(&*s, "eΦ⏣🌑");

let c = Char::get_mut(&mut *s, 1).unwrap();
assert!(c.replace('a').is_err());
§Errors
  • If r, when utf8 encoded, does not have the same length as self, LenNotEqual will be returned.
Examples found in repository?
examples/iter2.rs (line 10)
3
4
5
6
7
8
9
10
11
12
13
fn main() {
    let mut s = Box::<str>::from("Hello, World!");
    print!("{s:?}");

    // Capitalise all the 'l's.
    s.mut_iter()
        .filter(|c| c == &'l')
        .for_each(|c| c.replace('L').unwrap());

    println!(" -> {s:?}");
}
source

pub fn replace_with_pad_space<C>( &mut self, r: C ) -> Result<(), ReplacementTooLong>
where C: Into<char>,

Replace the character with another of the same length or shorter. The remaining bytes will be filled with spaces.

use mut_str::Char;

let mut s = Box::<str>::from("oΦ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
assert!(c.replace_with_pad_space('e').is_ok());
assert_eq!(&*s, "eΦ⏣🌑");

let c = Char::get_mut(&mut *s, 1).unwrap();
assert!(c.replace_with_pad_space('a').is_ok());
assert_eq!(&*s, "ea ⏣🌑");
§Errors
source

pub fn replace_with_pad<C>( &mut self, r: C, pad: u8 ) -> Result<(), ReplaceWithPadError>
where C: Into<char>,

Replace the character with another of the same length or shorter. The remaining bytes will be filled with pad.

use mut_str::Char;

let mut s = Box::<str>::from("oΦ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
assert!(c.replace_with_pad('e', b'b').is_ok());
assert_eq!(&*s, "eΦ⏣🌑");

let c = Char::get_mut(&mut *s, 1).unwrap();
assert!(c.replace_with_pad('a', b'b').is_ok());
assert_eq!(&*s, "eab⏣🌑");
§Errors
source

pub fn replace_with_pad_char<C1, C2>( &mut self, r: C1, pad_char: C2 ) -> Result<(), ReplaceWithPadCharError>
where C1: Into<char>, C2: Into<char>,

Replace the character with another of the same length or shorter. The remaining bytes will be filled with pad, which must be one byte long.

use mut_str::Char;

let mut s = Box::<str>::from("oΦ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
assert!(c.replace_with_pad_char('e', 'b').is_ok());
assert_eq!(&*s, "eΦ⏣🌑");

let c = Char::get_mut(&mut *s, 1).unwrap();
assert!(c.replace_with_pad_char('a', 'b').is_ok());
assert_eq!(&*s, "eab⏣🌑");
§Errors
Examples found in repository?
examples/char_replace.rs (line 13)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() {
    let mut s = Box::<str>::from("👋🌍");
    println!("Original string:       {s:?}"); // "👋🌍"

    // Get a mutable reference to the second character
    let world = s.get_char_mut(1).unwrap();
    println!("Original character:    {world:?}"); // '🌍'

    // Replace '🌍' with 'w' and '_' as padding
    // '🌍' is 4 bytes long and 'w' is 1, so 3 '_'s will be added after.
    world.replace_with_pad_char('w', '_').unwrap();
    println!("Replacement character: {world:?}"); // 'w'

    println!("Final string:          {s:?}"); // "👋w___"
}
source

pub fn replace_with_pad_left_space<C>( &mut self, r: C ) -> Result<&mut Self, ReplacementTooLong>
where C: Into<char>,

Replace the character with another of the same length or shorter, right aligned. The remaining bytes before the character will be filled with spaces.

use mut_str::Char;

let mut s = Box::<str>::from("oΦ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
assert!(c.replace_with_pad_left_space('e').is_ok());
assert_eq!(&*s, "eΦ⏣🌑");

let c = Char::get_mut(&mut *s, 1).unwrap();
let c2 = c.replace_with_pad_left_space('a').unwrap();
assert_eq!(c2, 'a');
assert_eq!(c, ' ');
assert_eq!(&*s, "e a⏣🌑");
§Errors
source

pub fn replace_with_pad_left<C>( &mut self, r: C, pad: u8 ) -> Result<&mut Self, ReplaceWithPadError>
where C: Into<char>,

Replace the character with another of the same length or shorter, right aligned. The remaining bytes before the character will be filled with pad.

use mut_str::Char;

let mut s = Box::<str>::from("oΦ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
assert!(c.replace_with_pad_left('e', b'b').is_ok());
assert_eq!(&*s, "eΦ⏣🌑");

let c = Char::get_mut(&mut *s, 1).unwrap();
let c2 = c.replace_with_pad_left('a', b'b').unwrap();
assert_eq!(c2, 'a');
assert_eq!(c, 'b');
assert_eq!(&*s, "eba⏣🌑");
§Errors
source

pub fn replace_with_pad_left_char<C1, C2>( &mut self, r: C1, pad_char: C2 ) -> Result<&mut Self, ReplaceWithPadCharError>
where C1: Into<char>, C2: Into<char>,

Replace the character with another of the same length or shorter, right aligned. The remaining bytes before the character will be filled with char, which must be one byte long.

use mut_str::Char;

let mut s = Box::<str>::from("oΦ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
assert!(c.replace_with_pad_left_char('e', 'b').is_ok());
assert_eq!(&*s, "eΦ⏣🌑");

let c = Char::get_mut(&mut *s, 1).unwrap();
let c2 = c.replace_with_pad_left_char('a', 'b').unwrap();
assert_eq!(c2, 'a');
assert_eq!(c, 'b');
assert_eq!(&*s, "eba⏣🌑");
§Errors
source

pub const fn is_ascii(&self) -> bool

Checks if the value is within ASCII range.

use mut_str::Char;

let s = "oΦ⏣🌑";

let c = Char::get(s, 0).unwrap();
assert!(c.is_ascii());

let c = Char::get(s, 1).unwrap();
assert!(!c.is_ascii());
source

pub fn make_ascii_uppercase(&mut self)

Converts this type to its ASCII upper case equivalent in-place.

ASCII letters ‘a’ to ‘z’ are mapped to ‘A’ to ‘Z’, but non-ASCII letters are unchanged.

use mut_str::Char;

let mut s = Box::<str>::from("oφ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
c.make_ascii_uppercase();

let c = Char::get_mut(&mut *s, 1).unwrap();
c.make_ascii_uppercase();

assert_eq!(&*s, "Oφ⏣🌑");
source

pub fn make_ascii_lowercase(&mut self)

Converts this type to its ASCII lower case equivalent in-place.

ASCII letters ‘A’ to ‘Z’ are mapped to ‘a’ to ‘z’, but non-ASCII letters are unchanged.

use mut_str::Char;

let mut s = Box::<str>::from("OΦ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
c.make_ascii_lowercase();

let c = Char::get_mut(&mut *s, 1).unwrap();
c.make_ascii_lowercase();

assert_eq!(&*s, "oΦ⏣🌑");
source

pub fn try_make_uppercase(&mut self) -> Result<(), LenNotEqual>

Converts this type to its Unicode upper case equivalent in-place.

use mut_str::Char;

let mut s = Box::<str>::from("oφ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
c.try_make_uppercase().unwrap();

let c = Char::get_mut(&mut *s, 1).unwrap();
c.try_make_uppercase().unwrap();

assert_eq!(&*s, "OΦ⏣🌑");
§Errors

If the character and its uppercase version is not the same length when utf8 encoded, LenNotEqual will be returned.

Examples found in repository?
examples/iter.rs (line 13)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() {
    let mut s = Box::<str>::from("oφ⏣🌑");

    // Iterate over the characters printing their length and bytes
    s.ref_iter()
        .for_each(|c| println!("{c:?}\tlength: {}, bytes: {:?}", c.len(), c.as_bytes()));

    // Iterate over each character trying to make them uppercase
    // (Result::ok is being used to ignore the result)
    s.mut_iter().for_each(|c| {
        c.try_make_uppercase().ok();
    });

    println!("\n{s:?}");
}
source

pub fn try_make_lowercase(&mut self) -> Result<(), LenNotEqual>

Converts this type to its Unicode lower case equivalent in-place.

use mut_str::Char;

let mut s = Box::<str>::from("OΦ⏣🌑");

let c = Char::get_mut(&mut *s, 0).unwrap();
c.try_make_lowercase().unwrap();

let c = Char::get_mut(&mut *s, 1).unwrap();
c.try_make_lowercase().unwrap();

assert_eq!(&*s, "oφ⏣🌑");
§Errors

If the character and its lowercase version is not the same length when utf8 encoded, LenNotEqual will be returned.

Trait Implementations§

source§

impl AsMut<Char> for OwnedChar

source§

fn as_mut(&mut self) -> &mut Char

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<str> for Char

source§

fn as_mut(&mut self) -> &mut str

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<Char> for OwnedChar

source§

fn as_ref(&self) -> &Char

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<str> for Char

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<Char> for OwnedChar

source§

fn borrow(&self) -> &Char

Immutably borrows from an owned value. Read more
source§

impl Borrow<str> for Char

source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
source§

impl BorrowMut<Char> for OwnedChar

source§

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

Mutably borrows from an owned value. Read more
source§

impl BorrowMut<str> for Char

source§

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

Mutably borrows from an owned value. Read more
source§

impl Debug for Char

source§

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

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

impl Display for Char

source§

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

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

impl<'a> Extend<&'a Char> for String

source§

fn extend<T: IntoIterator<Item = &'a Char>>(&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<'a> Extend<&'a mut Char> for String

source§

fn extend<T: IntoIterator<Item = &'a mut Char>>(&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<&Char> for OwnedChar

source§

fn from(value: &Char) -> Self

Converts to this type from the input type.
source§

impl From<&Char> for char

source§

fn from(value: &Char) -> Self

Converts to this type from the input type.
source§

impl<'a> FromIterator<&'a Char> for Box<str>

source§

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

Creates a value from an iterator. Read more
source§

impl<'a> FromIterator<&'a Char> for String

source§

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

Creates a value from an iterator. Read more
source§

impl<'a> FromIterator<&'a mut Char> for Box<str>

source§

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

Creates a value from an iterator. Read more
source§

impl<'a> FromIterator<&'a mut Char> for String

source§

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

Creates a value from an iterator. Read more
source§

impl FromStr for &Char

§

type Err = TryFromStrError

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 &Char

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 Ord for Char

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<Char> for char

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Char> for str

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<OwnedChar> for Char

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<char> for &Char

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<char> for &mut Char

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<char> for Char

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<str> for Char

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for Char

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Char> for char

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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd<Char> for str

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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd<OwnedChar> for Char

source§

fn partial_cmp(&self, other: &OwnedChar) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd<char> for Char

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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd<str> for Char

source§

fn partial_cmp(&self, other: &str) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd for Char

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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl ToOwned for Char

§

type Owned = OwnedChar

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> Self::Owned

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

fn clone_into(&self, target: &mut Self::Owned)

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

impl TryFrom<&[u8]> for &Char

§

type Error = TryFromBytesError

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

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&mut [u8]> for &mut Char

§

type Error = TryFromBytesError

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

fn try_from(value: &mut [u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&mut str> for &mut Char

§

type Error = TryFromStrError

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

fn try_from(value: &mut str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&str> for &Char

§

type Error = TryFromStrError

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

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Char

Auto Trait Implementations§

§

impl Freeze for Char

§

impl RefUnwindSafe for Char

§

impl Send for Char

§

impl Sync for Char

§

impl Unpin for Char

§

impl UnwindSafe for Char

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> 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> 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>,

§

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>,

§

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.