Skip to content

Commit 24554d0

Browse files
Assembling requested_families earlier (#5043)
1 parent 275f3f7 commit 24554d0

File tree

5 files changed

+154
-187
lines changed

5 files changed

+154
-187
lines changed

components/locale_core/src/langid.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ impl LanguageIdentifier {
144144
variants: subtags::Variants::new(),
145145
};
146146

147+
/// Whether this language identifier equals [`Self::UND`].
148+
pub const fn is_empty(&self) -> bool {
149+
self.language.is_empty()
150+
&& self.script.is_none()
151+
&& self.region.is_none()
152+
&& self.variants.is_empty()
153+
}
154+
147155
/// This is a best-effort operation that performs all available levels of canonicalization.
148156
///
149157
/// At the moment the operation will normalize casing and the separator, but in the future

components/locale_core/src/shortvec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<T> ShortBoxSlice<T> {
130130

131131
/// Returns whether the collection is empty.
132132
#[inline]
133-
pub fn is_empty(&self) -> bool {
133+
pub const fn is_empty(&self) -> bool {
134134
use ShortBoxSliceInner::*;
135135
matches!(self.0, ZeroOne(None))
136136
}

components/locale_core/src/subtags/language.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ impl Language {
9595
/// assert!(lang.is_empty());
9696
/// ```
9797
#[inline]
98-
pub fn is_empty(self) -> bool {
99-
self == Self::UND
98+
pub const fn is_empty(self) -> bool {
99+
matches!(self, Self::UND)
100100
}
101101
}
102102

components/locale_core/src/subtags/variants.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ impl Variants {
109109
core::mem::take(self)
110110
}
111111

112+
/// Whether the list of variants is empty.
113+
pub const fn is_empty(&self) -> bool {
114+
self.0.is_empty()
115+
}
116+
112117
pub(crate) fn for_each_subtag_str<E, F>(&self, f: &mut F) -> Result<(), E>
113118
where
114119
F: FnMut(&str) -> Result<(), E>,

0 commit comments

Comments
 (0)