Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions harfbuzz/src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ impl Language {
/// assert_eq!(lang.to_string(), "en-us");
/// ```
pub fn to_string(&self) -> &str {
// Since we panic if we have a non-UTF-8 language tag,
// we might as well panic on an invalid language tag,
// which is possible if allocation failed within HarfBuzz
// itself.
assert!(self.is_valid());
unsafe { core::ffi::CStr::from_ptr(sys::hb_language_to_string(self.raw)) }
.to_str()
.unwrap()
Expand Down
Loading