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>
impl CaseMapCloser<CaseMapper>
sourcepub const fn new() -> Self
pub const fn new() -> Self
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.
sourcepub fn try_new_with_any_provider(
provider: &(impl AnyProvider + ?Sized),
) -> Result<Self, DataError>
pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized), ) -> Result<Self, DataError>
A version of [Self :: new
] that uses custom data provided by an AnyProvider
.
sourcepub fn try_new_with_buffer_provider(
provider: &(impl BufferProvider + ?Sized),
) -> Result<Self, DataError>
pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), ) -> Result<Self, DataError>
A version of [Self :: new
] that uses custom data provided by a BufferProvider
.
✨ Enabled with the serde
feature.
sourcepub fn try_new_unstable<P>(provider: &P) -> Result<Self, DataError>
pub fn try_new_unstable<P>(provider: &P) -> Result<Self, DataError>
A version of Self::new
that uses custom data provided by a DataProvider
.
source§impl<CM: AsRef<CaseMapper>> CaseMapCloser<CM>
impl<CM: AsRef<CaseMapper>> CaseMapCloser<CM>
sourcepub fn try_new_with_mapper_with_any_provider(
provider: &(impl AnyProvider + ?Sized),
casemapper: CM,
) -> Result<Self, DataError>
pub fn try_new_with_mapper_with_any_provider( provider: &(impl AnyProvider + ?Sized), casemapper: CM, ) -> Result<Self, DataError>
A version of [Self :: new_with_mapper
] that uses custom data provided by an AnyProvider
.
sourcepub fn try_new_with_mapper_with_buffer_provider(
provider: &(impl BufferProvider + ?Sized),
casemapper: CM,
) -> Result<Self, DataError>
pub fn try_new_with_mapper_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), casemapper: CM, ) -> Result<Self, DataError>
A version of [Self :: new_with_mapper
] that uses custom data provided by a BufferProvider
.
✨ Enabled with the serde
feature.
sourcepub const fn new_with_mapper(casemapper: CM) -> Self
pub const fn new_with_mapper(casemapper: CM) -> Self
A constructor which creates a CaseMapCloser
from an existing CaseMapper
(either owned or as a reference)
✨ Enabled with the compiled_data
Cargo feature.
sourcepub fn try_new_with_mapper_unstable<P>(
provider: &P,
casemapper: CM,
) -> Result<Self, DataError>
pub fn try_new_with_mapper_unstable<P>( provider: &P, casemapper: CM, ) -> Result<Self, DataError>
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
.
sourcepub fn add_case_closure_to<S: ClosureSink>(&self, c: char, set: &mut S)
pub fn add_case_closure_to<S: ClosureSink>(&self, c: char, set: &mut S)
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
sourcepub fn add_string_case_closure_to<S: ClosureSink>(
&self,
s: &str,
set: &mut S,
) -> bool
pub fn add_string_case_closure_to<S: ClosureSink>( &self, s: &str, set: &mut S, ) -> bool
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> Clone for CaseMapCloser<CM>
impl<CM: Clone> Clone for CaseMapCloser<CM>
source§fn clone(&self) -> CaseMapCloser<CM>
fn clone(&self) -> CaseMapCloser<CM>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<CM: Debug> Debug for CaseMapCloser<CM>
impl<CM: Debug> Debug for CaseMapCloser<CM>
source§impl Default for CaseMapCloser<CaseMapper>
impl Default for CaseMapCloser<CaseMapper>
Auto Trait Implementations§
impl<CM> Freeze for CaseMapCloser<CM>where
CM: Freeze,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more