Skip to content

Commit

Permalink
Move casemap out of experimental; final graduation cleanups (#3803)
Browse files Browse the repository at this point in the history
* Move casemap to components

* rename dep spec

* Remove from experimental in datagen

* Remove from experimental in ffi

* Remove from experimental in metacrate

* Bump casemap version to 1.2.9

* review fixes

* depcheck

* make

* gn

* Example -> Examples

* add stability doc comment

* redirect docs

* compiled data in docs

* Fix feature flagging

* Add example with benchmark_macros

* fmt

* rm

* nit

---------

Co-authored-by: Robert Bastian <[email protected]>
  • Loading branch information
Manishearth and robertbastian authored Aug 9, 2023
1 parent a39cfed commit 1814f85
Show file tree
Hide file tree
Showing 50 changed files with 118 additions and 47 deletions.
4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# List of components with at least two owners as specified in docs/crate-ownership.

components/calendar/ @Manishearth @sffc
components/casemap/ @Manishearth
components/collator/ @hsivonen @echeran
components/collections/ @echeran
components/datetime/ @zbraniecki @gregtatum @nordzilla
Expand All @@ -20,7 +21,6 @@ components/plurals/ @zbraniecki @sffc
components/segmenter/ @aethanyc @makotokato @sffc
components/timezone/ @nordzilla
experimental/bies/ @sffc
experimental/casemap/ @Manishearth
experimental/compactdecimal/ @eggrobin
experimental/displaynames/ @sffc @snktd
experimental/harfbuzz/ @hsivonen
Expand Down Expand Up @@ -51,6 +51,7 @@ utils/zerofrom @Manishearth @sffc
utils/zerovec/ @Manishearth @sffc

components/calendar/data @unicode-org/icu4x-owners
components/casemap/data @unicode-org/icu4x-owners
components/collator/data @unicode-org/icu4x-owners
components/collections/data @unicode-org/icu4x-owners
components/datetime/data @unicode-org/icu4x-owners
Expand All @@ -61,7 +62,6 @@ components/normalizer/data @unicode-org/icu4x-owners
components/plurals/data @unicode-org/icu4x-owners
components/segmenter/data @unicode-org/icu4x-owners
components/timezone/data @unicode-org/icu4x-owners
experimental/casemap/data @unicode-org/icu4x-owners
experimental/compactdecimal/data @unicode-org/icu4x-owners
experimental/displaynames/data @unicode-org/icu4x-owners
experimental/relativetime/data @unicode-org/icu4x-owners
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ resolver = "2"
members = [
"components/calendar",
"components/calendar/data",
"components/casemap",
"components/casemap/data",
"components/collator",
"components/collator/data",
"components/collections",
Expand All @@ -32,8 +34,6 @@ members = [
"components/timezone",
"components/timezone/data",
"experimental/bies",
"experimental/casemap",
"experimental/casemap/data",
"experimental/compactdecimal",
"experimental/compactdecimal/data",
"experimental/displaynames",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[package]
name = "icu_casemap"
description = "Unicode case mapping and folding algorithms"
version = "0.7.2"
version = "1.2.0"
rust-version = "1.65.0"
authors = ["The ICU4X Project Developers"]
edition = "2021"
Expand All @@ -17,7 +17,6 @@ categories = ["internationalization"]
# Keep this in sync with other crates unless there are exceptions
include = [
"src/**/*",
"data/*",
"examples/**/*",
"benches/**/*",
"tests/**/*",
Expand Down Expand Up @@ -58,7 +57,9 @@ skip_optional_dependencies = true
denylist = ["bench"]

[dev-dependencies]
icu = { path = "../../components/icu" }
icu_normalizer = { path = "../../components/normalizer" }
icu_benchmark_macros = { path = "../../tools/benchmark/macros" }
icu_collections = { path = "../../components/collections", features = ["databake"] }
icu_codepointtrie_builder = { version = "0.3.4", path = "../../components/collections/codepointtrie_builder" }
databake = { version = "0.1.3", path = "../../utils/databake", default-features = false}
Expand Down
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions components/casemap/examples/casemapping.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

#![no_main] // https://github.com/unicode-org/icu4x/issues/395

icu_benchmark_macros::static_setup!();

use icu::casemap::CaseMapper;
use icu_locid::langid;

#[no_mangle]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
icu_benchmark_macros::main_setup!();

let cm = CaseMapper::new();

println!(
r#"The uppercase of "hello world" is "{}""#,
cm.uppercase_to_string("hello world", &langid!("und"))
);
println!(
r#"The lowercase of "Γειά σου Κόσμε" is "{}""#,
cm.lowercase_to_string("Γειά σου Κόσμε", &langid!("und"))
);

0
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ pub struct CaseMapCloser<CM> {

#[cfg(feature = "compiled_data")]
impl Default for CaseMapCloser<CaseMapper> {
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
fn default() -> Self {
Self::new()
}
}

impl CaseMapCloser<CaseMapper> {
/// A constructor which creates a [`CaseMapCloser`].
/// A constructor which creates a [`CaseMapCloser`] using compiled data.
///
/// # Examples
///
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! This module is published as its own crate ([`icu_casemap`](https://docs.rs/icu_casemap/latest/icu_casemap/))
//! and as part of the [`icu`](https://docs.rs/icu/latest/icu/) crate. See the latter for more details on the ICU4X project.
//!
//! # Example
//! # Examples
//!
//! ```rust
//! use icu_casemap::CaseMapper;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use icu_provider::prelude::*;
use writeable::Writeable;

/// How to handle the rest of the string once the head of the
/// string has been titlecased
/// string has been titlecased. See docs of [`TitlecaseMapper`] for examples.
#[non_exhaustive]
#[derive(Copy, Clone, Default, PartialEq, Eq, Hash, Debug)]
pub enum TailCasing {
Expand All @@ -26,7 +26,7 @@ pub enum TailCasing {
}

/// Whether to start casing at the beginning of the string or at the first
/// relevant character.
/// relevant character. See docs of [`TitlecaseMapper`] for examples.
#[non_exhaustive]
#[derive(Copy, Clone, Default, PartialEq, Eq, Hash, Debug)]
pub enum HeadAdjustment {
Expand All @@ -40,6 +40,8 @@ pub enum HeadAdjustment {
}

/// Various options for controlling titlecasing
///
/// See docs of [`TitlecaseMapper`] for examples.
#[non_exhaustive]
#[derive(Copy, Clone, Default, PartialEq, Eq, Hash, Debug)]
pub struct TitlecaseOptions {
Expand Down Expand Up @@ -144,7 +146,7 @@ pub struct TitlecaseMapper<CM> {
}

impl TitlecaseMapper<CaseMapper> {
/// A constructor which creates a [`TitlecaseMapper`], with the normal (non-legacy) head adjustment behavior.
/// A constructor which creates a [`TitlecaseMapper`] using compiled data, with the normal (non-legacy) head adjustment behavior.
/// See struct docs on [`TitlecaseMapper`] for more information on head adjustment behavior and usage examples.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
Expand All @@ -157,7 +159,7 @@ impl TitlecaseMapper<CaseMapper> {
gc: Some(icu_properties::maps::general_category().static_to_owned()),
}
}
/// A constructor which creates a [`TitlecaseMapper`], with the legacy head adjustment behavior.
/// A constructor which creates a [`TitlecaseMapper`] using compiled data, with the legacy head adjustment behavior.
/// See struct docs on [`TitlecaseMapper`] for more information on head adjustment behavior and usage examples.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
Expand Down Expand Up @@ -198,9 +200,7 @@ impl TitlecaseMapper<CaseMapper> {
let cm = CaseMapper::try_new_unstable(provider)?;
let gc = Some(
icu_properties::maps::load_general_category(provider).map_err(|e| {
let PropertiesError::PropDataLoad(e) = e else {
unreachable!()
};
let PropertiesError::PropDataLoad(e) = e else { unreachable!() };
e
})?,
);
Expand Down Expand Up @@ -229,7 +229,7 @@ impl<CM: AsRef<CaseMapper>> TitlecaseMapper<CM> {
]);

/// A constructor which creates a [`TitlecaseMapper`] from an existing [`CaseMapper`]
/// (either owned or as a reference), with the normal (non-legacy) head adjustment behavior.
/// (either owned or as a reference) and compiled data, with the normal (non-legacy) head adjustment behavior.
/// See struct docs on [`TitlecaseMapper`] for more information on head adjustment behavior.
///
/// ✨ *Enabled with the `compiled_data` Cargo feature.*
Expand Down Expand Up @@ -262,9 +262,7 @@ impl<CM: AsRef<CaseMapper>> TitlecaseMapper<CM> {
{
let gc = Some(
icu_properties::maps::load_general_category(provider).map_err(|e| {
let PropertiesError::PropDataLoad(e) = e else {
unreachable!()
};
let PropertiesError::PropDataLoad(e) = e else { unreachable!() };
e
})?,
);
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 5 additions & 6 deletions components/icu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ all-features = true

[dependencies]
icu_calendar = { version = "1.2.0", path = "../calendar", default-features = false }
icu_casemap = { version = "1.2.0", path = "../../components/casemap", default-features = false }
icu_collator = { version = "1.2.0", path = "../collator", default-features = false }
icu_collections = { version = "1.2.0", path = "../collections", default-features = false }
icu_datetime = { version = "1.2.0", path = "../datetime", default-features = false }
Expand All @@ -44,7 +45,6 @@ icu_segmenter = { version = "1.2.0", path = "../segmenter", default-features = f
icu_timezone = { version = "1.2.0", path = "../timezone", default-features = false }

# Experimental components
icu_casemap = { version = "0.7.1", path = "../../experimental/casemap", default-features = false, optional = true }
icu_compactdecimal = { version = "0.2.0", path = "../../experimental/compactdecimal", default-features = false, optional = true }
icu_displaynames = { version = "0.10.0", path = "../../experimental/displaynames", default-features = false, optional = true }
icu_relativetime = { version = "0.1.0", path = "../../experimental/relativetime", default-features = false, optional = true }
Expand All @@ -61,7 +61,7 @@ writeable = { path = "../../utils/writeable" }
[features]
default = [
"icu_calendar/default",
"icu_casemap?/default",
"icu_casemap/default",
"icu_collator/default",
"icu_compactdecimal?/default",
"icu_datetime/default",
Expand All @@ -78,7 +78,7 @@ default = [
]
std = [
"icu_calendar/std",
"icu_casemap?/std",
"icu_casemap/std",
"icu_collator/std",
"icu_collections/std",
"icu_datetime/std",
Expand All @@ -96,7 +96,7 @@ std = [
]
serde = [
"icu_calendar/serde",
"icu_casemap?/serde",
"icu_casemap/serde",
"icu_collator/serde",
"icu_collections/serde",
"icu_datetime/serde",
Expand All @@ -114,7 +114,7 @@ serde = [
]
compiled_data = [
"icu_calendar/compiled_data",
"icu_casemap?/compiled_data",
"icu_casemap/compiled_data",
"icu_collator/compiled_data",
"icu_compactdecimal?/compiled_data",
"icu_datetime/compiled_data",
Expand All @@ -136,7 +136,6 @@ icu_datetime_experimental = [
"icu_datetime/experimental",
]
experimental = [
"icu_casemap",
"icu_compactdecimal",
"icu_datetime_experimental",
"icu_displaynames",
Expand Down
1 change: 0 additions & 1 deletion components/icu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ extern crate icu_provider;
#[doc(inline)]
pub use icu_calendar as calendar;

#[cfg(feature = "icu_casemap")]
#[doc(inline)]
pub use icu_casemap as casemap;

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/testing/patch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[patch.crates-io]
icu_calendar = { path = "../../components/calendar" }
icu_calendar_data = { path = "../../components/calendar/data" }
icu_casemap = { path = "../../components/casemap" }
icu_casemap_data = { path = "../../components/casemap/data" }
icu_collator = { path = "../../components/collator" }
icu_collator_data = { path = "../../components/collator/data" }
icu_collections = { path = "../../components/collections" }
Expand All @@ -30,8 +32,6 @@ icu_segmenter_data = { path = "../../components/segmenter/data" }
icu_timezone = { path = "../../components/timezone" }
icu_timezone_data = { path = "../../components/timezone/data" }
bies = { path = "../../experimental/bies" }
icu_casemap = { path = "../../experimental/casemap" }
icu_casemap_data = { path = "../../experimental/casemap/data" }
icu_compactdecimal = { path = "../../experimental/compactdecimal" }
icu_compactdecimal_data = { path = "../../experimental/compactdecimal/data" }
icu_displaynames = { path = "../../experimental/displaynames" }
Expand Down
4 changes: 2 additions & 2 deletions ffi/diplomat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ cpp_default = ["logging"]
wasm_default = ["logging"]

# Components
default_components = ["icu_calendar", "icu_collator", "icu_datetime", "icu_decimal",
default_components = ["icu_calendar", "icu_casemap", "icu_collator", "icu_datetime", "icu_decimal",
"icu_list", "icu_locid_transform",
"icu_normalizer", "icu_plurals", "icu_properties",
"icu_segmenter", "icu_timezone"]
Expand Down Expand Up @@ -118,7 +118,7 @@ writeable = { version = "0.5.1", path = "../../utils/writeable/" }
# Optional ICU4X components and their dependent utils
fixed_decimal = { version = "0.5.2", path = "../../utils/fixed_decimal", features = ["ryu"] , optional = true}
icu_calendar = { version = "1.2.0", path = "../../components/calendar", default-features = false, optional = true }
icu_casemap = { version = "0.7.2", path = "../../experimental/casemap", default-features = false, optional = true }
icu_casemap = { version = "1.2.0", path = "../../components/casemap", default-features = false, optional = true }
icu_collator = { version = "1.2.0", path = "../../components/collator", default-features = false, optional = true }
icu_collections = { version = "1.2.0", path = "../../components/collections", default-features = false, optional = true }
icu_datetime = { version = "1.2.0", path = "../../components/datetime/", default-features = false, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion ffi/diplomat/cpp/examples/casemapping/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CXX?=g++
$(ALL_HEADERS):

../../../../../target/debug/libicu_capi_staticlib.a: FORCE
cargo build -p icu_capi_staticlib --features icu_capi/icu_casemap
cargo build -p icu_capi_staticlib

a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.cpp
$(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g
Expand Down
16 changes: 16 additions & 0 deletions ffi/gn/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1814f85

Please sign in to comment.