Add icu_data module for pretty-printer

korrat
May 17, 2024, 8:08 AM
PVRRMQEJNXQENYZIR2W7OLMJ2XA77B55W55B2O3APWZZUIUGLM7AC

Dependencies

  • [2] QRIJE4AQ add a simple pretty printer for beancount directives

Change contents

  • file addition: icu_data (d--r------)
    [2.53]
  • file addition: mod.rs (----------)
    [0.1]
    // @generated
    include!("macros.rs");
    macro_rules! impl_data_provider {
    ($ provider : ty) => {
    make_provider!($provider);
    impl_decimal_symbols_v1!($provider);
    };
    }
    #[allow(unused_macros)]
    macro_rules! impl_any_provider {
    ($ provider : ty) => {
    #[clippy::msrv = "1.67"]
    impl icu_provider::AnyProvider for $provider {
    fn load_any(&self, key: icu_provider::DataKey, req: icu_provider::DataRequest) -> Result<icu_provider::AnyResponse, icu_provider::DataError> {
    match key.hashed() {
    h if h == <icu_decimal::provider::DecimalSymbolsV1Marker as icu_provider::KeyedDataMarker>::KEY.hashed() => icu_provider::DataProvider::<icu_decimal::provider::DecimalSymbolsV1Marker>::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response),
    _ => Err(icu_provider::DataErrorKind::MissingDataKey.with_req(key, req)),
    }
    }
    }
    };
    }
    #[clippy::msrv = "1.67"]
    pub struct BakedDataProvider;
    impl_data_provider!(BakedDataProvider);
  • file addition: macros.rs (----------)
    [0.1]
    // @generated
    /// Marks a type as a data provider. You can then use macros like
    /// `impl_core_helloworld_v1` to add implementations.
    ///
    /// ```ignore
    /// struct MyProvider;
    /// const _: () = {
    /// include!("path/to/generated/macros.rs");
    /// make_provider!(MyProvider);
    /// impl_core_helloworld_v1!(MyProvider);
    /// }
    /// ```
    #[doc(hidden)]
    #[macro_export]
    macro_rules! __make_provider {
    ($ name : ty) => {
    #[clippy::msrv = "1.67"]
    impl $name {
    #[doc(hidden)]
    #[allow(dead_code)]
    pub const MUST_USE_MAKE_PROVIDER_MACRO: () = ();
    }
    };
    }
    #[doc(inline)]
    pub use __make_provider as make_provider;
    #[macro_use]
    #[path = "macros/decimal_symbols_v1.rs.data"]
    mod decimal_symbols_v1;
    #[doc(inline)]
    pub use __impl_decimal_symbols_v1 as impl_decimal_symbols_v1;
  • file addition: macros (d--r------)
    [0.1]
  • file addition: decimal_symbols_v1.rs.data (----------)
    [0.1998]
    // @generated
    /// Implement `DataProvider<DecimalSymbolsV1Marker>` on the given struct using the data
    /// hardcoded in this file. This allows the struct to be used with
    /// `icu`'s `_unstable` constructors.
    #[doc(hidden)]
    #[macro_export]
    macro_rules! __impl_decimal_symbols_v1 {
    ($ provider : ty) => {
    #[clippy::msrv = "1.67"]
    const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO;
    #[clippy::msrv = "1.67"]
    impl icu_provider::DataProvider<icu_decimal::provider::DecimalSymbolsV1Marker> for $provider {
    fn load(&self, req: icu_provider::DataRequest) -> Result<icu_provider::DataResponse<icu_decimal::provider::DecimalSymbolsV1Marker>, icu_provider::DataError> {
    static EN_AT: <icu_decimal::provider::DecimalSymbolsV1Marker as icu_provider::DataMarker>::Yokeable = icu_decimal::provider::DecimalSymbolsV1 { minus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("-"), suffix: alloc::borrow::Cow::Borrowed("") }, plus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("+"), suffix: alloc::borrow::Cow::Borrowed("") }, decimal_separator: alloc::borrow::Cow::Borrowed(","), grouping_separator: alloc::borrow::Cow::Borrowed("."), grouping_sizes: icu_decimal::provider::GroupingSizesV1 { primary: 3u8, secondary: 3u8, min_grouping: 1u8 }, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] };
    static EN_FI: <icu_decimal::provider::DecimalSymbolsV1Marker as icu_provider::DataMarker>::Yokeable = icu_decimal::provider::DecimalSymbolsV1 { minus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("-"), suffix: alloc::borrow::Cow::Borrowed("") }, plus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("+"), suffix: alloc::borrow::Cow::Borrowed("") }, decimal_separator: alloc::borrow::Cow::Borrowed(","), grouping_separator: alloc::borrow::Cow::Borrowed("\u{a0}"), grouping_sizes: icu_decimal::provider::GroupingSizesV1 { primary: 3u8, secondary: 3u8, min_grouping: 1u8 }, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] };
    static EN_IN: <icu_decimal::provider::DecimalSymbolsV1Marker as icu_provider::DataMarker>::Yokeable = icu_decimal::provider::DecimalSymbolsV1 { minus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("-"), suffix: alloc::borrow::Cow::Borrowed("") }, plus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("+"), suffix: alloc::borrow::Cow::Borrowed("") }, decimal_separator: alloc::borrow::Cow::Borrowed("."), grouping_separator: alloc::borrow::Cow::Borrowed(","), grouping_sizes: icu_decimal::provider::GroupingSizesV1 { primary: 3u8, secondary: 2u8, min_grouping: 1u8 }, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] };
    static UND: <icu_decimal::provider::DecimalSymbolsV1Marker as icu_provider::DataMarker>::Yokeable = icu_decimal::provider::DecimalSymbolsV1 { minus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("-"), suffix: alloc::borrow::Cow::Borrowed("") }, plus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("+"), suffix: alloc::borrow::Cow::Borrowed("") }, decimal_separator: alloc::borrow::Cow::Borrowed("."), grouping_separator: alloc::borrow::Cow::Borrowed(","), grouping_sizes: icu_decimal::provider::GroupingSizesV1 { primary: 3u8, secondary: 3u8, min_grouping: 1u8 }, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] };
    static EN_CH: <icu_decimal::provider::DecimalSymbolsV1Marker as icu_provider::DataMarker>::Yokeable = icu_decimal::provider::DecimalSymbolsV1 { minus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("-"), suffix: alloc::borrow::Cow::Borrowed("") }, plus_sign_affixes: icu_decimal::provider::AffixesV1 { prefix: alloc::borrow::Cow::Borrowed("+"), suffix: alloc::borrow::Cow::Borrowed("") }, decimal_separator: alloc::borrow::Cow::Borrowed("."), grouping_separator: alloc::borrow::Cow::Borrowed("’"), grouping_sizes: icu_decimal::provider::GroupingSizesV1 { primary: 3u8, secondary: 3u8, min_grouping: 1u8 }, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] };
    static VALUES: [&<icu_decimal::provider::DecimalSymbolsV1Marker as icu_provider::DataMarker>::Yokeable; 12usize] = [&EN_AT, &EN_AT, &EN_CH, &EN_AT, &EN_AT, &EN_FI, &EN_AT, &EN_IN, &EN_AT, &EN_FI, &EN_AT, &UND];
    static KEYS: [&str; 12usize] = ["en-AT", "en-BE", "en-CH", "en-DE", "en-DK", "en-FI", "en-ID", "en-IN", "en-NL", "en-SE", "en-SI", "und"];
    let mut metadata = icu_provider::DataResponseMetadata::default();
    let payload = if let Ok(payload) = KEYS.binary_search_by(|k| req.locale.strict_cmp(k.as_bytes()).reverse()).map(|i| *unsafe { VALUES.get_unchecked(i) }) {
    payload
    } else {
    const FALLBACKER: icu_locid_transform::fallback::LocaleFallbackerWithConfig<'static> = icu_locid_transform::fallback::LocaleFallbacker::new().for_config(<icu_decimal::provider::DecimalSymbolsV1Marker as icu_provider::KeyedDataMarker>::KEY.fallback_config());
    let mut fallback_iterator = FALLBACKER.fallback_for(req.locale.clone());
    loop {
    if let Ok(payload) = KEYS.binary_search_by(|k| fallback_iterator.get().strict_cmp(k.as_bytes()).reverse()).map(|i| *unsafe { VALUES.get_unchecked(i) }) {
    metadata.locale = Some(fallback_iterator.take());
    break payload;
    }
    fallback_iterator.step();
    }
    };
    Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(payload)), metadata })
    }
    }
    };
    }
  • file addition: any.rs (----------)
    [0.1]
    // @generated
    impl_any_provider!(BakedDataProvider);