Struct icu::casemap::CaseMapCloser

source ·
pub struct CaseMapCloser<CM> { /* private fields */ }
Expand description

A wrapper around CaseMapper that can produce case mapping closures over a character or string. This wrapper can be constructed directly, or by wrapping a reference to an existing CaseMapper.

Examples

use icu_casemap::CaseMapCloser;
use icu_collections::codepointinvlist::CodePointInversionListBuilder;

let cm = CaseMapCloser::new();
let mut builder = CodePointInversionListBuilder::new();
let found = cm.add_string_case_closure_to("ffi", &mut builder);
assert!(found);
let set = builder.build();

assert!(set.contains('ffi'));

let mut builder = CodePointInversionListBuilder::new();
let found = cm.add_string_case_closure_to("ss", &mut builder);
assert!(found);
let set = builder.build();

assert!(set.contains('ß'));
assert!(set.contains('ẞ'));

Implementations§

source§

impl CaseMapCloser<CaseMapper>

source

pub const fn new() -> CaseMapCloser<CaseMapper>

A constructor which creates a CaseMapCloser using compiled data.

Examples
use icu_casemap::CaseMapCloser;
use icu_collections::codepointinvlist::CodePointInversionListBuilder;

let cm = CaseMapCloser::new();
let mut builder = CodePointInversionListBuilder::new();
let found = cm.add_string_case_closure_to("ffi", &mut builder);
assert!(found);
let set = builder.build();

assert!(set.contains('ffi'));

let mut builder = CodePointInversionListBuilder::new();
let found = cm.add_string_case_closure_to("ss", &mut builder);
assert!(found);
let set = builder.build();

assert!(set.contains('ß'));
assert!(set.contains('ẞ'));

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized) ) -> Result<CaseMapCloser<CaseMapper>, DataError>

A version of Self::new that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized) ) -> Result<CaseMapCloser<CaseMapper>, DataError>

A version of Self::new that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_unstable<P>( provider: &P ) -> Result<CaseMapCloser<CaseMapper>, DataError>where P: DataProvider<CaseMapV1Marker> + DataProvider<CaseMapUnfoldV1Marker> + ?Sized,

A version of Self::new that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source§

impl<CM> CaseMapCloser<CM>where CM: AsRef<CaseMapper>,

source

pub fn try_new_with_mapper_with_any_provider( provider: &(impl AnyProvider + ?Sized), casemapper: CM ) -> Result<CaseMapCloser<CM>, DataError>

A version of Self::new_with_mapper that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_with_mapper_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), casemapper: CM ) -> Result<CaseMapCloser<CM>, DataError>

A version of Self::new_with_mapper that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub const fn new_with_mapper(casemapper: CM) -> CaseMapCloser<CM>

A constructor which creates a CaseMapCloser from an existing CaseMapper (either owned or as a reference)

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_with_mapper_unstable<P>( provider: &P, casemapper: CM ) -> Result<CaseMapCloser<CM>, DataError>where P: DataProvider<CaseMapV1Marker> + DataProvider<CaseMapUnfoldV1Marker> + ?Sized,

Construct this object to wrap an existing CaseMapper (or a reference to one), loading additional data as needed. A version of Self::new_with_mapper that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn add_case_closure_to<S>(&self, c: char, set: &mut S)where S: ClosureSink,

Adds all simple case mappings and the full case folding for c to set. Also adds special case closure mappings.

In other words, this adds all strings/characters that this casemaps to, as well as all characters that may casemap to this one.

The character itself is not added.

For example, the mappings

  • for s include long s
  • for sharp s include ss
  • for k include the Kelvin sign

This function is identical to CaseMapper::add_case_closure_to(); if you don’t need Self::add_string_case_closure_to() consider using a CaseMapper to avoid loading additional data.

Examples
use icu_casemap::CaseMapCloser;
use icu_collections::codepointinvlist::CodePointInversionListBuilder;

let cm = CaseMapCloser::new();
let mut builder = CodePointInversionListBuilder::new();
cm.add_case_closure_to('s', &mut builder);

let set = builder.build();

assert!(set.contains('S'));
assert!(set.contains('ſ'));
assert!(!set.contains('s')); // does not contain itself
source

pub fn add_string_case_closure_to<S>(&self, s: &str, set: &mut S) -> boolwhere S: ClosureSink,

Finds all characters and strings which may casemap to s as their full case folding string and adds them to the set. Includes the full case closure of each character mapping.

In other words, this performs a reverse full case folding and then adds the case closure items of the resulting code points.

The string itself is not added to the set.

Returns true if the string was found

Examples
use icu_casemap::CaseMapCloser;
use icu_collections::codepointinvlist::CodePointInversionListBuilder;

let cm = CaseMapCloser::new();
let mut builder = CodePointInversionListBuilder::new();
let found = cm.add_string_case_closure_to("ffi", &mut builder);
assert!(found);
let set = builder.build();

assert!(set.contains('ffi'));

let mut builder = CodePointInversionListBuilder::new();
let found = cm.add_string_case_closure_to("ss", &mut builder);
assert!(found);
let set = builder.build();

assert!(set.contains('ß'));
assert!(set.contains('ẞ'));

Trait Implementations§

source§

impl<CM> Clone for CaseMapCloser<CM>where CM: Clone,

source§

fn clone(&self) -> CaseMapCloser<CM>

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<CM> Debug for CaseMapCloser<CM>where CM: Debug,

source§

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

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

impl Default for CaseMapCloser<CaseMapper>

source§

fn default() -> CaseMapCloser<CaseMapper>

Enabled with the compiled_data Cargo feature.

Auto Trait Implementations§

§

impl<CM> RefUnwindSafe for CaseMapCloser<CM>where CM: RefUnwindSafe,

§

impl<CM> Send for CaseMapCloser<CM>where CM: Send,

§

impl<CM> Sync for CaseMapCloser<CM>where CM: Sync,

§

impl<CM> Unpin for CaseMapCloser<CM>where CM: Unpin,

§

impl<CM> UnwindSafe for CaseMapCloser<CM>where CM: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere 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 Twhere 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.
§

impl<T> ErasedDestructor for Twhere T: 'static,

source§

impl<T> MaybeSendSync for Twhere T: Send + Sync,