We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d7e3737 commit 647c411Copy full SHA for 647c411
1 file changed
harfbuzz/src/language.rs
@@ -68,6 +68,11 @@ impl Language {
68
/// assert_eq!(lang.to_string(), "en-us");
69
/// ```
70
pub fn to_string(&self) -> &str {
71
+ // Since we panic if we have a non-UTF-8 language tag,
72
+ // we might as well panic on an invalid language tag,
73
+ // which is possible if allocation failed within HarfBuzz
74
+ // itself.
75
+ assert!(self.is_valid());
76
unsafe { core::ffi::CStr::from_ptr(sys::hb_language_to_string(self.raw)) }
77
.to_str()
78
.unwrap()
0 commit comments