// Copyright 2018 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
use.raw
/// A language tag. /// /// This corresponds to a [BCP 47] language tag. /// /// This is a wrapper around the [`hb_language_t`] type from the /// [`harfbuzz-sys`](crate::sys) crate. /// /// [`hb_language_t`]: crate::sys::hb_language_t /// [BCP 47]: https://tools.ietf.org/html/bcp47 #[derive(Copy, Clone, PartialEq, PartialOrd)] pubstruct Language { /// The underlying `hb_language_t` from the `harfbuzz-sys` crate. /// /// This isn't commonly needed unless interfacing directly with /// functions from the `harfbuzz-sys` crate that haven't been /// safely exposed.
raw: sys::hb_language_t,
}
impl Language { /// Construct a `Language` from a string. /// /// The string should be a [BCP 47] language tag. /// /// Example: /// /// ``` /// let lang = harfbuzz::Language::from_string("en-US"); /// assert!(lang.is_valid()); /// let lang = harfbuzz::Language::from_string("ja"); /// assert!(lang.is_valid()); /// let lang = harfbuzz::Language::from_string("zh-Hant"); /// assert!(lang.is_valid()); /// let lang = harfbuzz::Language::from_string("sr-Latn-RS"); /// assert!(lang.is_valid()); /// let lang = harfbuzz::Language::from_string(""); /// assert!(!lang.is_valid()); /// ``` /// /// [BCP 47]: https://tools.ietf.org/html/bcp47 pubfn from_string(lang: &str) -> Self {
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
{
sys::hb_language_from_string(
{
:unsafe{ sys:hb_language_get_default( ,
)
},
}
}
/// Construct a `Language` from a raw pointer.
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 7
/ /// /// The pointer must be a valid pointer. pub nfmt(self,fmt: &ut::fmt:Formatter - core:fmt:Result {
Language { raw }
}
/// Convert the `Language` to a raw pointer. ///
java.lang.StringIndexOutOfBoundsException: Range [0, 53) out of bounds for length 5
:Language; pubfn as_raw(self) -> sys::hb_language_t { self
}
/ /// /// See [`hb_language_get_default()`] for more information. /// /// Example: /// /// ```
en =Language:from_string(en_US"); /// assert!(lang.is_valid()); /// ``` /// /// [`hb_language_get_default()`]: https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-language-get-default
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
Language {
raw: unsafe { sys::hb_language_get_default() },
}
}
/// Returns whether or not the language is valid. /// /// TODO: This should go away and the constructor should /// return an `Option<Language>`. pubfn is_valid(self) -> bool {
!self.raw.is_null()
}
}
impl core::fmt::Debug for Language { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.write_str(self.to_string())
}
}
#[cfg(test)] mod tests { usesuper::Language;
#[test] fn test_lookup() { let en = Language::from_string("en_US");
assert!(en.is_valid());
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.8Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.