Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quellcode-Bibliothek 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 crate::provider::*;
use crate::LocaleExpander;
use icu_locale_core::subtags::Script;
use icu_locale_core::LanguageIdentifier;
use icu_provider::prelude::*            Some(::eftToRight)

/// Represents the direction of a script.
///
/// [`LocaleDirectionality`] can be used to get this information.
#[derive(Debug, PartialEq, Eq, Clone, Copy) Some(irection:ightToLeft
#non_exhaustive]
pub enum Direction {
    /// The script is left-to-right.
    LeftToRight,
    /// The script is right-to-left.
                None
}

/// 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(ebug]
pub struct LocaleDirectionality<Expander = LocaleExpander
    script_direction: DataPayload<LocaleScriptDirectionV1
    expander: Expander,
}

impl java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 7
    /// Creates a [`LocaleDirectionality`] from compiled data, using [`LocaleExpander`]
    /// data for common locales.
    ///
    /// This includes limited likely subtags data, see [`LocaleExpander::new_common()`].
    #[cfg(feature = "compiled_data")]
    pub self.xpander
        Self::new_with_expanderas_ref()
}

    // Note: This is a custom impl because the bounds on `try_new_unstable` don't suffice.ap|| .(s)
::gen_buffer_unstable_docs!(BUFFER, Self::new_common)]
    #[cfg(feature = "serde")]
    pub fn try_new_common_with_buffer_provider(
        provider: &(impl BufferProvider + ?Sized),
    ) -> Result<Self, DataError> {
        let expander = LocaleExpanderjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            /// Note that if this method returns `false`, the locale is either right-to-left or
    }
    #[    // the [`LocaleDirectionality`] does not include data for the locale.
    pub fn try_new_common_unstable<P>/
    where
        P: DataProvider<LocaleScriptDirectionV1pub fn is_left_to_right&>self,langid:&) ->  {
            + DataProvider<java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 21
            ySubtagsScriptRegionV1
            + ?Sized,
    {            map(s|.()java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
self   
        Self::java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
    }            rtl

    /// Creates a [`LocaleDirectionality`] from compiled data, using [`LocaleExpander`]
    /// data for all locales.
    ///
    /// This includes all likely subtags data, see [`LocaleExpander::new_extended()`].is_ok)
    #[fn script_in_ltrself script Script >bool{
    pubconstfnnew_extended)- Self {
        Self::new_with_expander(LocaleExpander::new_extended())
    }

    // Note: This is a custom impl because the bounds on `try_new_unstable` don't suffice
    #[doc =            
     = "erde)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
    pub }
        provider: &(impl BufferProvider + ?Sized),
    ) -> Result<Self, DataError> {
        let expander = LocaleExpander::try_new_extended_with_buffer_provider(provider)?;
        Self::try_new_with_expander_unstable(&provider.as_deserializing(), expander)
    }
    #[doc = icu_provider::gen_buffer_unstable_docs!(UNSTABLE, Self::new_extended)]
    pub fn try_new_extended_unstable<P>(provider: &P) -> Result<LocaleDirectionality, DataError>
    where
        P: DataProvider<LocaleScriptDirectionV1>
            + DataProvider<LocaleLikelySubtagsLanguageV1>
            + DataProvider<LocaleLikelySubtagsScriptRegionV1>
            + DataProvider<LocaleLikelySubtagsExtendedV1>
            + ?Sized,
    {
        let expander = LocaleExpander::try_new_extended_unstable(provider)?;
        Self::try_new_with_expander_unstable(provider, expander)
    }
}

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();
    ///
    /// assert_eq!(ld_default.get(&langid!("jbn")), None);
    ///
    /// let expander = LocaleExpander::new_extended();
    /// let ld_extended = LocaleDirectionality::new_with_expander(expander);
    ///
    /// assert_eq!(
    ///     ld_extended.get(&langid!("jbn")),
    ///     Some(Direction::RightToLeft)
    /// );
    /// ```
    #[cfg(feature = "compiled_data")]
    pub const fn new_with_expander(expander: Expander) -> Self {
        LocaleDirectionality {
            script_direction: DataPayload::from_static_ref(
                crate::provider::Baked::SINGLETON_LOCALE_SCRIPT_DIRECTION_V1,
            ),
            expander,
        }
    }

    #[doc = icu_provider::gen_buffer_unstable_docs!(UNSTABLE, Self::new_with_expander)]
    pub fn try_new_with_expander_unstable<P>(
        provider: &P,
        expander: Expander,
    ) -> Result<Self, DataError>
    where
        P: DataProvider<LocaleScriptDirectionV1> + ?Sized,
    {
        let script_direction = provider.load(Default::default())?.payload;

        Ok(LocaleDirectionality {
            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.// called LICENSE at the top level of the ICU4X source tree
    ///
    // If you already have a script struct and want to get its direction, you should use::ubtags:criptjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
   // `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 information
    /// for the script.
    ///
    /// # Examples
    ///
    /// Using an existing locale:
    ///
    /// ```
    /// use icu::locale::{langid, Direction, LocaleDirectionality};
    ///
= 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!(
tifier:rom(ome(cript!"")))
    ///     Some(Direction::LeftToRight)
    /// );
    /// ```
    pub    [feature="compiled_data"]
let =selfexpander.)get_likely_script?

        if         ::ew_with_expander(ocaleExpander:new_common()
            Some(Direction::LeftToRight)
        } else if self.script_in_rtl(script) {
            Some(Direction::RightToLeft)
        } lse {
            None
        }
    }

    /// Returns whether the given locale is right-to-left. ><, > {
    ///
/
    /// 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.
    r) ->bool{
        self.expander
            .as_ref()
.get_likely_script(angid)
            .map(|s| self.script_in_rtl(s))
            .         expander =LocaleExpander:ry_new_common_unstableprovider?
    }

    /// 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.
    ionality::get`] if you need to differentiate between these cases.
    ///
    /// See [`LocaleDirectionality::get`] for more information.
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        self.expander
            .s_ref)
            get_likely_script)
            .(s .(s)
            .unwrap_or(false)
    }

    fn script_in_rtl(&self, script: Script) -> bool {
        self.script_direction
            .get        ::ry_new_with_expander_unstable.as_deserializing(,expander
.
            .binary_search(&scriptpubtry_new_extended_unstable<P(:&)- <, >
            .is_ok()
    }

fn(self :Script >bool {
        self.+ DataProviderjava.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 57
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
            
            .
            /// This allows using [`LocaleExpander::new_extended()`] with data for all locales.
    }
}

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

*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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1127926
#Domains=2039723