Skip to content

Commit 739c3ed

Browse files
committed
Fix some issues in language_tag.rs that somehow got missed
1 parent 8575925 commit 739c3ed

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/property/language_tag.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::UnknownValueError;
44

55
/// The subset of BCP 47 language tags permitted by the EditorConfig standard.
66
///
7-
/// This type doesn't implement [`PropertyValue`].
7+
/// This type doesn't implement [`PropertyValue`][crate::PropertyValue].
88
/// See [`SpellingLanguage`][super::SpellingLanguage].
99
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
1010
pub struct LanguageTag([u8; 4]);
@@ -33,11 +33,13 @@ impl LanguageTag {
3333
}
3434
/// Returns the language subtag, e.g. the "en" in "en-US".
3535
pub fn primary_language(&self) -> &str {
36+
#[allow(clippy::missing_panics_doc)]
3637
std::str::from_utf8(&self.0[0..2]).expect("Non-UTF-8 bytes in LanguageTag")
3738
}
3839
/// Returns the region subtag, if any, e.g. the "US" in "en-US".
3940
pub fn region(&self) -> Option<&str> {
4041
let slice = &self.0[2..4];
42+
#[allow(clippy::missing_panics_doc)]
4143
(*slice != [0, 0])
4244
.then(|| std::str::from_utf8(slice).expect("Non-UTF-8 bytes in LanguageTag"))
4345
}
@@ -46,9 +48,9 @@ impl LanguageTag {
4648
impl std::fmt::Display for LanguageTag {
4749
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4850
if let Some(region) = self.region() {
49-
write!(f, "{}-{}", self.language(), region)
51+
write!(f, "{}-{}", self.primary_language(), region)
5052
} else {
51-
write!(f, "{}", self.language())
53+
write!(f, "{}", self.primary_language())
5254
}
5355
}
5456
}

0 commit comments

Comments
 (0)