• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zbraniecki / icu4x / 6815798908

09 Nov 2023 05:17PM CUT coverage: 72.607% (-2.4%) from 75.01%
6815798908

push

github

web-flow
Implement `Any/BufferProvider` for some smart pointers (#4255)

Allows storing them as a `Box<dyn Any/BufferProvider>` without using a
wrapper type that implements the trait.

44281 of 60987 relevant lines covered (72.61%)

201375.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/components/collections/src/codepointinvlist/mod.rs
1
// This file is part of ICU4X. For terms of use, please see the file
2
// called LICENSE at the top level of the ICU4X source tree
3
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4

5
//! This module provides necessary functionality for highly efficient querying of sets of Unicode characters.
6
//!
7
//! It is an implementation of the code point portion of the existing
8
//! [ICU4C UnicodeSet API](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1UnicodeSet.html).
9
//!
10
//! # Architecture
11
//! ICU4X [`CodePointInversionList`] is split up into independent levels, with [`CodePointInversionList`] representing the membership/query API,
12
//! and [`CodePointInversionListBuilder`] representing the builder API.
13
//!
14
//! # Examples:
15
//!
16
//! ## Creating a `CodePointInversionList`
17
//!
18
//! CodePointSets are created from either serialized [`CodePointSets`](CodePointInversionList),
19
//! represented by [inversion lists](http://userguide.icu-project.org/strings/properties),
20
//! the [`CodePointInversionListBuilder`], or from the Properties API.
21
//!
22
//! ```
23
//! use icu_collections::codepointinvlist::{
24
//!     CodePointInversionList, CodePointInversionListBuilder,
25
//! };
26
//!
27
//! let mut builder = CodePointInversionListBuilder::new();
28
//! builder.add_range(&('A'..='Z'));
29
//! let set: CodePointInversionList = builder.build();
30
//!
31
//! assert!(set.contains('A'));
32
//! ```
33
//!
34
//! ## Querying a `CodePointInversionList`
35
//!
36
//! Currently, you can check if a character/range of characters exists in the [`CodePointInversionList`], or iterate through the characters.
37
//!
38
//! ```
39
//! use icu_collections::codepointinvlist::{
40
//!     CodePointInversionList, CodePointInversionListBuilder,
41
//! };
42
//!
43
//! let mut builder = CodePointInversionListBuilder::new();
44
//! builder.add_range(&('A'..='Z'));
45
//! let set: CodePointInversionList = builder.build();
46
//!
47
//! assert!(set.contains('A'));
48
//! assert!(set.contains_range(&('A'..='C')));
49
//! assert_eq!(set.iter_chars().next(), Some('A'));
50
//! ```
51
//!
52
//! [`ICU4X`]: ../icu/index.html
53

54
#![warn(missing_docs)]
55

56
extern crate alloc;
57

58
#[macro_use]
59
mod builder;
60
mod conversions;
61
mod cpinvlist;
62
mod utils;
63

64
use alloc::vec::Vec;
65

66
pub use builder::CodePointInversionListBuilder;
67
pub use conversions::*;
68
pub use cpinvlist::CodePointInversionList;
69
pub use cpinvlist::CodePointInversionListULE;
70
use displaydoc::Display;
71

72
/// Custom Errors for [`CodePointInversionList`].
73
///
74
/// Re-exported as [`Error`].
75
#[derive(Display, Debug)]
1✔
76
pub enum CodePointInversionListError {
77
    /// A CodePointInversionList was constructed with an invalid inversion list
78
    #[displaydoc("Invalid set: {0:?}")]
79
    InvalidSet(Vec<u32>),
1✔
80
    /// A CodePointInversionList was constructed containing an invalid range
81
    #[displaydoc("Invalid range: {0}..{1}")]
×
82
    InvalidRange(u32, u32),
×
83
}
84

85
#[cfg(feature = "std")]
86
impl std::error::Error for CodePointInversionListError {}
87

88
#[doc(no_inline)]
89
pub use CodePointInversionListError as Error;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc