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

zbraniecki / icu4x / 9457158389

10 Jun 2024 11:45PM UTC coverage: 75.174% (+0.05%) from 75.121%
9457158389

push

github

web-flow
Add constructing TinyAsciiStr from utf16 (#5025)

Introduces TinyAsciiStr constructors from utf16 and converges on the
consensus from #4931.

---------

Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>

65 of 82 new or added lines in 14 files covered. (79.27%)

3441 existing lines in 141 files now uncovered.

52850 of 70304 relevant lines covered (75.17%)

563298.06 hits per line

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

0.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 cpinvlist::CodePointInversionList;
68
pub use cpinvlist::CodePointInversionListULE;
69
use displaydoc::Display;
70

UNCOV
71
#[derive(Display, Debug)]
×
72
/// A CodePointInversionList was constructed with an invalid inversion list
73
#[displaydoc("Invalid set: {0:?}")]
UNCOV
74
pub struct InvalidSetError(pub Vec<u32>);
×
75

76
/// A CodePointInversionList was constructed from an invalid range
UNCOV
77
#[derive(Display, Debug)]
×
UNCOV
78
#[displaydoc("Invalid range: {0}..{1}")]
×
UNCOV
79
pub struct RangeError(pub u32, pub u32);
×
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