Struct CharRange
struct CharRange { ... }
A range of unicode code points.
The most idiomatic way to construct this range is through the use of the chars! macro:
extern crate unic_char_range;
use CharRange;
#
If constructed in reverse order, such that self.high is ordered before self.low,
the range is empty. If you want to iterate in decreasing order, use .iter().rev().
All empty ranges are considered equal no matter the internal state.
Fields
low: charThe lowest character in this range (inclusive).
high: charThe highest character in this range (inclusive).
Implementations
impl CharRange
fn contains(self: &Self, ch: char) -> boolDoes this range include a character?
Examples
# use CharRange; assert!; assert!; assert!; assert!;fn cmp_char(self: &Self, ch: char) -> OrderingDetermine the ordering of this range and a character.
Panics
Panics if the range is empty. This fn may be adjusted in the future to not panic in optimized builds. Even if so, an empty range will never compare as
Ordering::Equal.fn len(self: &Self) -> usizeHow many characters are in this range?
fn is_empty(self: &Self) -> boolIs this range empty?
fn iter(self: &Self) -> CharIterCreate an iterator over this range.
impl CharRange
fn closed(start: char, stop: char) -> CharRangeConstruct a closed range of characters.
If
stopis ordered beforestart, the resulting range will be empty.Example
# use *; assert_eq!fn open_right(start: char, stop: char) -> CharRangeConstruct a half open (right) range of characters.
Example
# use *; assert_eq!fn open_left(start: char, stop: char) -> CharRangeConstruct a half open (left) range of characters.
Example
# use *; assert_eq!fn open(start: char, stop: char) -> CharRangeConstruct a fully open range of characters.
Example
# use *; assert_eq!fn all() -> CharRangeConstruct a range over all Unicode characters (Unicode Scalar Values).
fn assigned_normal_planes() -> CharRangeConstruct a range over all characters of assigned Unicode Planes.
Assigned normal (non-special) Unicode Planes are:
- Plane 0: Basic Multilingual Plane (BMP)
- Plane 1: Supplementary Multilingual Plane (SMP)
- Plane 2: Supplementary Ideographic Plane (SIP)
Unicode Plane 14, Supplementary Special-purpose Plane (SSP), is not included in this range, mainly because of the limit of
CharRangeonly supporting a continuous range.Unicode Planes 3 to 13 are Unassigned planes and therefore excluded.
Unicode Planes 15 and 16 are Private Use Area planes and won't have Unicode-assigned characters.
impl Clone for CharRange
fn clone(self: &Self) -> CharRange
impl Copy for CharRange
impl Debug for CharRange
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for CharRange
impl Freeze for CharRange
impl From for CharRange
fn from(iter: CharIter) -> CharRange
impl IntoIterator for CharRange
fn into_iter(self: Self) -> CharIter
impl PartialEq for CharRange
fn eq(self: &Self, other: &CharRange) -> bool
impl RefUnwindSafe for CharRange
impl Send for CharRange
impl Sync for CharRange
impl Unpin for CharRange
impl UnsafeUnpin for CharRange
impl UnwindSafe for CharRange
impl<T> Any for CharRange
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for CharRange
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for CharRange
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for CharRange
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for CharRange
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for CharRange
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for CharRange
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for CharRange
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>