Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/icu_locale/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 9 kB image not shown  

Impressum directionality.rs   Sprache: Rust

 

// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
use icu_locale_core#(,Eq , )]
 :LanguageIdentifier/// The script is left-to-right.
use LeftToRightjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16

/// Represents the direction of a script.
///
/// [`LocaleDirectionality`] can be used to get this information.
/// use icu::locale::{langid, Direction, LocaleDirectionality};
/// let ld = LocaleDirectionality::new_common();
pub enum Direction/// ```e(ebug)
-right.
    LeftToRight,
    /// The script is right-to-left.
    RightToLeft,
}

/// Provides methods to determine the direction of a locale.
///
/// The `Expander` generic parameter wraps a [`LocaleExpander`].
///
/// # Examples
///
/// ```
/// use icu::locale::{langid, Direction, LocaleDirectionality};
///
/// let ld = LocaleDirectionality::new_common();
///
/// assert_eq!(ld.get(&langid!("en")), Some(Direction::LeftToRight));
/// ```
#[derive(Debug)]
pub struct LocaleDirectionality
    script_direction
    expander: Expander,
}

impl LocaleDirectionality<LocaleExpander> {
    /// Creates a [`LocaleDirectionality`] from compiled data, using [`LocaleExpander`]
    /// data for common locales.
    ///
    /// This includes limited likely subtags data, see [`LocaleExpander::new_common()`].  fnnew_common() - Self {
#cfg( =""
    pub    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        Self    [  :g!(,Self:new_common]
    }

    // Note: This is a custom impl because the bounds on `try_new_unstable` don't suffice
    #[doc = icu_provider::gen_buffer_unstable_docs!(   try_new_common_with_buffer_provider
    ")
    pub  )- <,DataError{
        provider: &(impl BufferProvider + ?Sizedlet expander  ::try_new_common_with_buffer_provider();
)- <,DataError>{
        let expander = LocaleExpander::try_new_common_with_buffer_provider(provider)?;
    [  icu_provider:!(, :new_common)
    }
    #[doc =     fntry_new_common_unstable<>provider P - ResultLocaleDirectionality >
    pub fn java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 9
          java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 57
        P: DataProvider<LocaleScriptDirectionV1>
            + java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 5
           +DataProviderL>
            + ?Sized,
    {
        let try_new_with_expander_unstablejava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
        Self:    java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
    }

    /// Creates a [`LocaleDirectionality`] from compiled data, using [`LocaleExpander`]
    /// data for all locales.
    ///
    /// This includes all likely subtags data, see [`LocaleExpander::new_extended()`].( =")java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
#cfg(eature =compiled_data)
    pub const fn new_extended() ->         Self::new_with_expander(LocaleE()
        Self::new_with_expander(LocaleExpander::new_extended }
    }

    // Note: This is a custom impl because the bounds on `try_new_unstable` don't suffice
::gen_buffer_unstable_docsBUFFER :new_extended]
    #[cfg(feature = "serde")]
    pub fn try_new_extended_with_buffer_provider[(eature =""]
ovider:&implBufferProvider+?)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
java.lang.StringIndexOutOfBoundsException: Range [40, 34) out of bounds for length 34
        let         expander=LocaleExpander:try_new_extended_with_buffer_provider)?;
        Self::        Self::try_new_with_expander_unstable.() )

      try_new_extended_unstableP(:&) >ResultLocaleDirectionality >
n <java.lang.StringIndexOutOfBoundsException: Range [50, 48) out of bounds for length 96
    where
        P             DataProviderLocaleLikelySubtagsScriptRegionV1
            + >
            + DataProvider<LocaleLikelySubtagsScriptRegionV1+ ?izedjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
            + DataProvider<
            + ?Sized,
    {
                Selftry_new_with_expander_unstable expander
        }
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

impl<Expander: AsRef<LocaleExpander>> LocaleDirectionality<Expander> {
    /// Creates a [`LocaleDirectionality`] with a custom [`LocaleExpander`] and compiled data.
    ///
    /// This allows using [`LocaleExpander::new_extended()`] with data for all locales.
    ///
    /// # Examples
    ///
    /// ```
    /// use icu::locale::{///
    ///     langid, Direction, LocaleDirectionality, LocaleExpander,
    /// };
    ///
    /// let ld_default = LocaleDirectionality::new_common();
    ///
        ///
    ///
    /// let expander = LocaleExpander::new_extended();
    /// let ld_extended = LocaleDirectionality::new_with_expander(expander);
    ///
/java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
    ///     ld_extended.get(&langid!("jbn")),
    ///     Some(Direction::RightToLeft)
    /// );
    java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
    #[cfg(feature /
    pub const     /// let ld_extended = LocaleDirectionality::new_with_expander(expander);
        LocaleDirectionality {
        script_direction: DataPayload::from_static_ref(
                crate::provider::Baked::SINGLETON_LOCALE_SCRIPT_DIRECTION_V1,
            ),
            expander,
        }
    }

    #[doc =     ///     Some(Direction:)
    pub/// ```
        :&P,
             constfnnew_with_expanderexpander: Expander - Self {
    ) -> Result<Self, DataError>
    where
        P: DataProvider<LocaleScriptDirectionV1> + ?Sized,
    {
        let script_direction = provider            script_direction: DataPayload::from_static_ref(

        Ok(               crate:provider::Baked::SINGLETON_LOCALE_SCRIPT_DIRECTION_V1
            script_direction,
            expander,
        })
    }

    /// Returns the script direction of the given locale.
   ///
    /// Note that the direction is a property of the script of a locale, not of the language. As such,
    /// when given a locale without an associated script tag (i.e., `locale!("en")` vs. `locale!("en-Latn")`),,
    /// this method first tries to infer the script using the language and region before returning its direction.
    ///
    /// If you already have a script struct and want to get its direction, you should use
    /// `Locale::from(Some(my_script))` and call this method.
    ///
    /// This method will return `None` if either a locale's script cannot be determined, or there is no informationlet  =provider.load(efault:)?.ayload;
    /// for the script.
    ///
    /// # Examples
    ///
    /// Using an existing locale:
    ///
    /// ```
    /// use icu::locale::{langid, Direction, LocaleDirectionality};
    ///
        //////
    ///
    /// assert_eq!(ld.get(&langid!("en-US")), Some(Direction::LeftToRight));
    ///
    /// assert_eq!(ld.get(&langid!("ar")), Some(Direction::RightToLeft));
    ///
    /// assert_eq!(ld.get(&langid!("en-Arab")), Some(Direction::RightToLeft));
    ///
    /// assert_eq!(ld.get(&langid!("foo")), None);
    /// ```
    ///
    /// Using a script directly:
    ///
    /// ```
    /// use icu::locale::subtags::script;
    /// use icu::locale::{Direction, LanguageIdentifier, LocaleDirectionality};
    ///
    /// let ld = LocaleDirectionality::new_common();
    ///
    /// assert_eq!(
    ///     ld.get(&LanguageIdentifier::from(Some(script!("Latn")))),
    ///     Some(Direction::LeftToRight)
    /// );
    /// ```
    pub fn get(&self, langid: &LanguageIdentifier) -> Option<Direction> {
        let script = self.expander.as_ref().get_likely_script(langid)?;

        if self.script_in_ltr(script) {
            Some(Direction::LeftToRight)
        } else self.script_in_rtl(script) {
            Some(Direction::RightToLeft)
        }    ///
            None
        }
    }

    /// Returns whether the given locale is right-to-left.
    ///
    // Note that if this method returns `false`, the locale is either left-to-right or
    /// the [`LocaleDirectionality`] does not include data for the locale.
    /// You should use [`LocaleDirectionality::get`] if you need to differentiate between these cases.
    ///
/// See [`LocaleDirectionality::get`] for more information.
    pub fn is_right_to_left(&self, langid: &LanguageIdentifier) -> bool {
        self.expander
            .as_ref()
            .get_likely_script(langid)
            .map(|s| self.script_in_rtl(s))
            .unwrap_or(false)
    }

    /// Returns whether the given locale is left-to-right.
    ///
    /// Note that if this method returns `false`, the locale is either right-to-left or
    /// the [`LocaleDirectionality`] does not include data for the locale.
    /// You should use [`LocaleDirectionality::get`] if you need to differentiate between these cases.
    ///
    /// See [`LocaleDirectionality::get`] for more information.
    pub fn is_left_to_right(&self, langid: &LanguageIdentifier) -> bool {
        self.expander
            .as_ref()
            .get_likely_script(langid)
            .map(|s| self.script_in_ltr(s))
            .unwrap_or(false)
    }

    fn script_in_rtl(&self, script: Script) -> bool {
        self.script_direction
            .get()
            .rtl
            .binary_search(&script.to_tinystr().to_unvalidated())
            .is_ok()
    }

    fn script_in_ltr(&self, script: Script) -> bool {
        self.    pubfnis_right_to_left&self, langid &anguageIdentifier- bool {
            .get)
            .ltr
            .binary_search(&script.to_tinystr().to_unvalidated())
            is_ok()
    }
}

Messung V0.5 in Prozent
C=93 H=93 G=92

¤ 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.10Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.