-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename _legacy to _adjust_to_cased #3826
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,15 +54,15 @@ pub struct TitlecaseOptions { | |
} | ||
|
||
/// A wrapper around [`CaseMapper`] that can compute titlecasing stuff, and is able to load additional data | ||
/// to support the non-legacy "head adjustment" behavior. | ||
/// to support the non-"adjust to cased" "head adjustment" behavior. | ||
/// | ||
/// | ||
/// By default, [`Self::titlecase_segment()`] and [`Self::titlecase_segment_to_string()`] perform "head adjustment", | ||
/// where they wait till the first relevant character to begin titlecasing. For example, in the string `'twixt`, the apostrophe | ||
/// is ignored because the word starts at the first "t", which will get titlecased (producing `'Twixt`). Other punctuation will | ||
/// also be ignored, like in the string `«hello»`, which will get titlecased to `«Hello»`. | ||
/// | ||
/// Opinions on exactly what is a "relevant" character may differ. In "legacy" mode the first cased character is considered "relevant", | ||
/// Opinions on exactly what is a "relevant" character may differ. In "adjust to cased" mode the first cased character is considered "relevant", | ||
/// whereas in the normal mode, it is the first character that is a letter, number, symbol, or private use character. This means | ||
/// that the strings `49ers` and `«丰(abc)»` will titlecase to `49Ers` and `«丰(Abc)»`, whereas in the normal mode they stay unchanged. | ||
/// This difference largely matters for things that mix numbers and letters, or mix writing systems, within a single segment. | ||
|
@@ -111,7 +111,7 @@ pub struct TitlecaseOptions { | |
/// use icu_locid::langid; | ||
/// | ||
/// let cm_normal = TitlecaseMapper::new(); | ||
/// let cm_legacy = TitlecaseMapper::new_legacy(); | ||
/// let cm_adjust_to_cased = TitlecaseMapper::new_adjust_to_cased(); | ||
/// let root = langid!("und"); | ||
/// | ||
/// let default_options = Default::default(); | ||
|
@@ -120,17 +120,17 @@ pub struct TitlecaseOptions { | |
/// | ||
/// // Exhibits head adjustment when set: | ||
/// assert_eq!(cm_normal.titlecase_segment_to_string("«hello»", &root, default_options), "«Hello»"); | ||
/// assert_eq!(cm_legacy.titlecase_segment_to_string("«hello»", &root, default_options), "«Hello»"); | ||
/// assert_eq!(cm_adjust_to_cased.titlecase_segment_to_string("«hello»", &root, default_options), "«Hello»"); | ||
/// assert_eq!(cm_normal.titlecase_segment_to_string("«hello»", &root, no_adjust), "«hello»"); | ||
/// | ||
/// // Only changed in legacy mode: | ||
/// assert_eq!(cm_normal.titlecase_segment_to_string("丰(abc)", &root, default_options), "丰(abc)"); | ||
/// assert_eq!(cm_legacy.titlecase_segment_to_string("丰(abc)", &root, default_options), "丰(Abc)"); | ||
/// assert_eq!(cm_adjust_to_cased.titlecase_segment_to_string("丰(abc)", &root, default_options), "丰(Abc)"); | ||
/// assert_eq!(cm_normal.titlecase_segment_to_string("丰(abc)", &root, no_adjust), "丰(abc)"); | ||
/// | ||
/// // Only changed in legacy mode: | ||
/// assert_eq!(cm_normal.titlecase_segment_to_string("49ers", &root, default_options), "49ers"); | ||
/// assert_eq!(cm_legacy.titlecase_segment_to_string("49ers", &root, default_options), "49Ers"); | ||
/// assert_eq!(cm_adjust_to_cased.titlecase_segment_to_string("49ers", &root, default_options), "49Ers"); | ||
/// assert_eq!(cm_normal.titlecase_segment_to_string("49ers", &root, no_adjust), "49ers"); | ||
/// ``` | ||
/// <div class="stab unstable"> | ||
|
@@ -146,7 +146,7 @@ pub struct TitlecaseMapper<CM> { | |
} | ||
|
||
impl TitlecaseMapper<CaseMapper> { | ||
/// A constructor which creates a [`TitlecaseMapper`] using compiled data, with the normal (non-legacy) head adjustment behavior. | ||
/// A constructor which creates a [`TitlecaseMapper`] using compiled data, with the normal (non-"adjust to cased") 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.* | ||
|
@@ -159,14 +159,14 @@ impl TitlecaseMapper<CaseMapper> { | |
gc: Some(icu_properties::maps::general_category().static_to_owned()), | ||
} | ||
} | ||
/// A constructor which creates a [`TitlecaseMapper`] using compiled data, with the legacy head adjustment behavior. | ||
/// A constructor which creates a [`TitlecaseMapper`] using compiled data, with the "adjust to cased" 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.* | ||
/// | ||
/// [📚 Help choosing a constructor](icu_provider::constructors) | ||
#[cfg(feature = "compiled_data")] | ||
pub const fn new_legacy() -> Self { | ||
pub const fn new_adjust_to_cased() -> Self { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: on second thought, we don't really need this constructor. People can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if they want to still have it be the same type, though? Might make it clunky There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's kind-of confusing that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah but the choice of behaviors affects data; we had kinda discussed this model and the 2x2 chart with the merged cells There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. People who care about their data have a path; people who don't care as much about their data have a cleaner API. I think that's slightly better than a confusing API that affects everyone. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you proposing we remove specifically the compiled_data adjust_to_cased ctor? That seems okay. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What should we do over FFI, then? |
||
Self { | ||
cm: CaseMapper::new(), | ||
gc: None, | ||
|
@@ -185,10 +185,10 @@ impl TitlecaseMapper<CaseMapper> { | |
icu_provider::gen_any_buffer_data_constructors!(locale: skip, options: skip, error: DataError, | ||
#[cfg(skip)] | ||
functions: [ | ||
new_legacy, | ||
try_new_legacy_with_any_provider, | ||
try_new_legacy_with_buffer_provider, | ||
try_new_legacy_unstable, | ||
new_adjust_to_cased, | ||
try_new_adjust_to_cased_with_any_provider, | ||
try_new_adjust_to_cased_with_buffer_provider, | ||
try_new_adjust_to_cased_unstable, | ||
Self, | ||
]); | ||
|
||
|
@@ -207,7 +207,7 @@ impl TitlecaseMapper<CaseMapper> { | |
Ok(Self { cm, gc }) | ||
} | ||
#[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::new)] | ||
pub fn try_new_legacy_unstable<P>(provider: &P) -> Result<Self, DataError> | ||
pub fn try_new_adjust_to_cased_unstable<P>(provider: &P) -> Result<Self, DataError> | ||
where | ||
P: DataProvider<CaseMapV1Marker> + ?Sized, | ||
{ | ||
|
@@ -247,7 +247,7 @@ impl<CM: AsRef<CaseMapper>> TitlecaseMapper<CM> { | |
/// See struct docs on [`TitlecaseMapper`] for more information on head adjustment behavior. | ||
/// | ||
/// [📚 Help choosing a constructor](icu_provider::constructors) | ||
pub const fn new_with_mapper_legacy(casemapper: CM) -> Self { | ||
pub const fn new_with_mapper_adjust_to_cased(casemapper: CM) -> Self { | ||
Self { | ||
cm: casemapper, | ||
gc: None, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"head adjustment" is confusing. I have never heard "head" used in discussion of titlecasing.
How about "titlecasing index adjustment" or similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've been calling this HeadAdjustment and TailCasing which I think has a nice symmetry. "Index adjustment" feels more internal, I think "head" is quite clear personally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bikeshed: