Struct CodePointInversionList
struct CodePointInversionList<'data> { ... }
A membership wrapper for CodePointInversionList.
Provides exposure to membership functions and constructors from serialized CodePointSets (sets of code points)
and predefined ranges.
Implementations
impl<'data> CodePointInversionList<'data>
fn try_from_inversion_list(inv_list: ZeroVec<'data, PotentialCodePoint>) -> Result<Self, InvalidSetError>Returns a new
CodePointInversionListfrom an inversion list represented as aZeroVec<PotentialCodePoint>of code points.The inversion list must be of even length, sorted ascending non-overlapping, and within the bounds of
0x0 -> 0x10FFFFinclusive, and end points being exclusive.Examples
use CodePointInversionList; use InvalidSetError; use PotentialCodePoint; use ZeroVec; let valid = ; let inv_list: = valid .into_iter .map .collect; let result = try_from_inversion_list; assert!; let invalid = vec!; let inv_list: = invalid .iter .copied .map .collect; let result = try_from_inversion_list; assert!; if let Err = resultfn all() -> SelfReturns
CodePointInversionListspanning entire Unicode rangeThe range spans from
0x0 -> 0x10FFFFinclusive.Examples
use CodePointInversionList; let expected = ; assert_eq!; assert_eq!;fn bmp() -> SelfReturns
CodePointInversionListspanning BMP rangeThe range spans from
0x0 -> 0xFFFFinclusive.Examples
use CodePointInversionList; const BMP_MAX: u32 = 0xFFFF; let expected = ; assert_eq!; assert_eq!;fn iter_chars(self: &Self) -> impl Iterator<Item = char> + '_Yields an
Iteratorgoing through the character set in theCodePointInversionListExamples
use CodePointInversionList; let example_list = ; let example = try_from_u32_inversion_list_slice .unwrap; let mut ex_iter_chars = example.iter_chars; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!;fn iter_ranges(self: &Self) -> impl ExactSizeIterator<Item = RangeInclusive<u32>> + '_Yields an
Iteratorreturning the ranges of the code points that are included in theCodePointInversionListRanges are returned as
RangeInclusive, which is inclusive of itsendbound value. An end-inclusive behavior matches the ICU4C/J behavior of ranges, ex:CodePointInversionList::contains(UChar32 start, UChar32 end).Example
use CodePointInversionList; let example_list = ; let example = try_from_u32_inversion_list_slice .unwrap; let mut example_iter_ranges = example.iter_ranges; assert_eq!; assert_eq!; assert_eq!;fn iter_ranges_complemented(self: &Self) -> impl Iterator<Item = RangeInclusive<u32>> + '_Yields an
Iteratorreturning the ranges of the code points that are not included in theCodePointInversionListRanges are returned as
RangeInclusive, which is inclusive of itsendbound value. An end-inclusive behavior matches the ICU4C/J behavior of ranges, ex:CodePointInversionList::contains(UChar32 start, UChar32 end).Example
use CodePointInversionList; let example_list = ; let example = try_from_u32_inversion_list_slice .unwrap; let mut example_iter_ranges = example.iter_ranges_complemented; assert_eq!; assert_eq!; assert_eq!; assert_eq!;fn get_range_count(self: &Self) -> usizeReturns the number of ranges contained in this
CodePointInversionListfn get_nth_range(self: &Self, idx: usize) -> Option<RangeInclusive<u32>>Returns a specific range contained in this
CodePointInversionListby index. Intended for use in FFI.fn size(self: &Self) -> usizeReturns the number of elements of the
CodePointInversionListfn is_empty(self: &Self) -> boolReturns whether or not the
CodePointInversionListis emptyfn contains(self: &Self, query: char) -> boolChecks to see the query is in the
CodePointInversionListRuns a binary search in
O(log(n))wherenis the number of start and end points in the set usingcoreimplementationExamples
use CodePointInversionList; let example_list = ; let example = try_from_u32_inversion_list_slice .unwrap; assert!; assert!;fn contains32(self: &Self, query: u32) -> boolChecks to see the unsigned int is in the
CodePointInversionList::all()Note: Even though
u32and [prim@char] in Rust are non-negative 4-byte values, there is an important difference. Au32can take values up to a very large integer value, while a [prim@char] in Rust is defined to be in the range from 0 to the maximum valid Unicode Scalar Value.Runs a binary search in
O(log(n))wherenis the number of start and end points in the set usingcoreimplementationExamples
use CodePointInversionList; let example_list = ; let example = try_from_u32_inversion_list_slice .unwrap; assert!; assert!;fn contains_range<impl RangeBounds<char>: RangeBounds<char>>(self: &Self, range: impl RangeBounds<char>) -> boolChecks to see if the range is in the
CodePointInversionListRuns a binary search in
O(log(n))wherenis the number of start and end points in the set usingVecimplementation. Only runs the search once on thestartparameter, while theendparameter is checked in a singleO(1)step.Examples
use CodePointInversionList; let example_list = ; let example = try_from_u32_inversion_list_slice .unwrap; assert!; assert!; assert!;Surrogate points (
0xD800 -> 0xDFFF) will returnfalseif the Range contains them but theCodePointInversionListdoes not.Note: when comparing to ICU4C/J, keep in mind that
Ranges in Rust are constructed inclusive of start boundary and exclusive of end boundary. The ICU4C/JCodePointInversionList::contains(UChar32 start, UChar32 end)method differs by including the end boundary.Examples
use CodePointInversionList; use char; let check = charfrom_u32.unwrap..charfrom_u32.unwrap; let example_list = ; let example = try_from_u32_inversion_list_slice .unwrap; assert!;fn contains_set(self: &Self, set: &Self) -> boolCheck if the calling
CodePointInversionListcontains all the characters of the givenCodePointInversionListExamples
use CodePointInversionList; let example_list = ; // A - E, U - Z let example = try_from_u32_inversion_list_slice .unwrap; let a_to_d = try_from_u32_inversion_list_slice .unwrap; let f_to_t = try_from_u32_inversion_list_slice .unwrap; let r_to_x = try_from_u32_inversion_list_slice .unwrap; assert!; // contains all assert!; // contains none assert!; // contains somefn span(self: &Self, span_str: &str, contained: bool) -> usizeReturns the end of the initial substring where the characters are either contained/not contained in the set.
Examples
use CodePointInversionList; let example_list = ; // {A, B, C} let example = try_from_u32_inversion_list_slice .unwrap; assert_eq!; assert_eq!; assert_eq!; assert_eq!;fn span_back(self: &Self, span_str: &str, contained: bool) -> usizeReturns the start of the trailing substring (starting from end of string) where the characters are either contained/not contained in the set. Returns the length of the string if no valid return.
Examples
use CodePointInversionList; let example_list = ; // {A, B, C} let example = try_from_u32_inversion_list_slice .unwrap; assert_eq!; assert_eq!; assert_eq!;
impl<'a> Yokeable for CodePointInversionList<'static>
fn transform(self: &'a Self) -> &'a <Self as >::Outputfn transform_owned(self: Self) -> <Self as >::Outputunsafe fn make(this: <Self as >::Output) -> Selffn transform_mut<F>(self: &'a mut Self, f: F) where F: 'static + for<'b> FnOnce(&'b mut <Self as >::Output)
impl<'data> Clone for CodePointInversionList<'data>
fn clone(self: &Self) -> CodePointInversionList<'data>
impl<'data> Debug for CodePointInversionList<'data>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<'data> EncodeAsVarULE for CodePointInversionList<'data>
fn encode_var_ule_as_slices<R, impl FnOnce(&[&[u8]]) -> R: FnOnce(&[&[u8]]) -> R>(self: &Self, cb: impl FnOnce(&[&[u8]]) -> R) -> Rfn encode_var_ule_len(self: &Self) -> usizefn encode_var_ule_write(self: &Self, dst: &mut [u8])
impl<'data> Eq for CodePointInversionList<'data>
impl<'data> Freeze for CodePointInversionList<'data>
impl<'data> From for CodePointInversionList<'data>
fn from(other: &'data CodePointInversionListULE) -> Self
impl<'data> PartialEq for CodePointInversionList<'data>
fn eq(self: &Self, other: &CodePointInversionList<'data>) -> bool
impl<'data> RefUnwindSafe for CodePointInversionList<'data>
impl<'data> Send for CodePointInversionList<'data>
impl<'data> StructuralPartialEq for CodePointInversionList<'data>
impl<'data> Sync for CodePointInversionList<'data>
impl<'data> Unpin for CodePointInversionList<'data>
impl<'data> UnsafeUnpin for CodePointInversionList<'data>
impl<'data> UnwindSafe for CodePointInversionList<'data>
impl<'data> ZeroFrom for CodePointInversionList<'data>
fn zero_from(other: &'data CodePointInversionListULE) -> Self
impl<'zf, 'zf_inner> ZeroFrom for CodePointInversionList<'zf>
fn zero_from(this: &'zf CodePointInversionList<'zf_inner>) -> Self
impl<T> Any for CodePointInversionList<'data>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for CodePointInversionList<'data>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for CodePointInversionList<'data>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for CodePointInversionList<'data>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> ErasedDestructor for CodePointInversionList<'data>
impl<T> From for CodePointInversionList<'data>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for CodePointInversionList<'data>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for CodePointInversionList<'data>
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 CodePointInversionList<'data>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for CodePointInversionList<'data>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>