Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into tiny
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Jul 2, 2024
2 parents f2b687c + 157a37b commit 36f0a97
Show file tree
Hide file tree
Showing 86 changed files with 3,055 additions and 172 deletions.
20 changes: 10 additions & 10 deletions components/datetime/src/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ macro_rules! gen_any_buffer_constructors_with_external_loader {
&provider.as_downcasting(),
&ExternalLoaderAny(provider),
locale,
$($arg),+
$($arg.into()),+
)
}
#[doc = icu_provider::gen_any_buffer_unstable_docs!(BUFFER, Self::$compiled_fn)]
Expand All @@ -74,7 +74,7 @@ macro_rules! gen_any_buffer_constructors_with_external_loader {
&provider.as_deserializing(),
&ExternalLoaderBuffer(provider),
locale,
$($arg),+
$($arg.into()),+
)
}
};
Expand Down Expand Up @@ -394,7 +394,7 @@ impl<C: CldrCalendar, R: TypedDateTimeMarkers<C> + IsRuntimeComponents> TypedNeo
&crate::provider::Baked,
&ExternalLoaderCompiledData,
locale,
components,
components.into(),
length,
)
}
Expand Down Expand Up @@ -440,7 +440,7 @@ impl<C: CldrCalendar, R: TypedDateTimeMarkers<C> + IsRuntimeComponents> TypedNeo
provider,
&ExternalLoaderUnstable(provider),
locale,
components,
components.into(),
length,
)
}
Expand All @@ -451,7 +451,7 @@ impl<C: CldrCalendar, R: TypedDateTimeMarkers<C>> TypedNeoFormatter<C, R> {
provider: &P,
loader: &L,
locale: &DataLocale,
components: impl Into<NeoComponents>,
components: NeoComponents,
length: NeoSkeletonLength,
) -> Result<Self, LoadError>
where
Expand All @@ -478,7 +478,7 @@ impl<C: CldrCalendar, R: TypedDateTimeMarkers<C>> TypedNeoFormatter<C, R> {
&R::DateTimePatternV1Marker::bind(provider),
locale,
length,
components.into(),
components,
)
.map_err(LoadError::Data)?;
let mut names = RawDateTimeNames::new_without_fixed_decimal_formatter();
Expand Down Expand Up @@ -980,7 +980,7 @@ impl<R: DateTimeMarkers + IsRuntimeComponents> NeoFormatter<R> {
&crate::provider::Baked,
&ExternalLoaderCompiledData,
locale,
components,
components.into(),
length,
)
}
Expand Down Expand Up @@ -1081,7 +1081,7 @@ impl<R: DateTimeMarkers + IsRuntimeComponents> NeoFormatter<R> {
provider,
&ExternalLoaderUnstable(provider),
locale,
components,
components.into(),
length,
)
}
Expand All @@ -1092,7 +1092,7 @@ impl<R: DateTimeMarkers> NeoFormatter<R> {
provider: &P,
loader: &L,
locale: &DataLocale,
components: impl Into<NeoComponents>,
components: NeoComponents,
length: NeoSkeletonLength,
) -> Result<Self, LoadError>
where
Expand Down Expand Up @@ -1169,7 +1169,7 @@ impl<R: DateTimeMarkers> NeoFormatter<R> {
&R::DateTimePatternV1Marker::bind(provider),
locale,
length,
components.into(),
components,
)
.map_err(LoadError::Data)?;
let mut names = RawDateTimeNames::new_without_fixed_decimal_formatter();
Expand Down
2 changes: 2 additions & 0 deletions components/experimental/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub mod provider {
impl_long_compact_decimal_format_data_v1_marker!(Baked);
impl_short_compact_decimal_format_data_v1_marker!(Baked);
impl_currency_essentials_v1_marker!(Baked);
impl_units_essentials_v1_marker!(Baked);
impl_units_display_name_v1_marker!(Baked);
impl_language_display_names_v1_marker!(Baked);
impl_locale_display_names_v1_marker!(Baked);
Expand Down Expand Up @@ -92,6 +93,7 @@ pub mod provider {
super::compactdecimal::provider::ShortCompactDecimalFormatDataV1Marker::INFO,
super::dimension::provider::currency::CurrencyEssentialsV1Marker::INFO,
super::dimension::provider::percent::PercentEssentialsV1Marker::INFO,
super::dimension::provider::units_essentials::UnitsEssentialsV1Marker::INFO,
super::dimension::provider::units::UnitsDisplayNameV1Marker::INFO,
super::displaynames::provider::LanguageDisplayNamesV1Marker::INFO,
super::displaynames::provider::LocaleDisplayNamesV1Marker::INFO,
Expand Down
22 changes: 11 additions & 11 deletions components/icu/examples/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use icu::timezone::CustomTimeZone;
use icu_collections::codepointinvlist::CodePointInversionListBuilder;
use std::env;

fn print<T: AsRef<str>>(_input: T) {
#[cfg(debug_assertions)]
println!("{}", _input.as_ref());
#[cfg(not(debug_assertions))]
macro_rules! println {
($($arg:tt)*) => {};
}

#[no_mangle]
Expand All @@ -40,9 +40,9 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {
})
.unwrap_or(5);

print(format!("\nTextual User Interface Example ({locale})"));
print("===================================");
print(format!("User: {user_name}"));
println!("\nTextual User Interface Example ({locale})");
println!("===================================");
println!("User: {user_name}");

{
let dtf = TypedZonedDateTimeFormatter::<Gregorian>::try_new(
Expand All @@ -56,7 +56,7 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {

let formatted_dt = dtf.format(&today_date, &today_tz);

print(format!("Today is: {formatted_dt}"));
println!("Today is: {formatted_dt}");
}

{
Expand All @@ -68,9 +68,9 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {
let only_latin1 = user_name.chars().all(|ch| latin1_set.contains(ch));

if only_latin1 {
print("User name latin1 only: true");
println!("User name latin1 only: true");
} else {
print("User name latin1 only: false");
println!("User name latin1 only: false");
}
}

Expand All @@ -79,8 +79,8 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {
.expect("Failed to create PluralRules.");

match pr.category_for(email_count) {
PluralCategory::One => print("Note: You have one unread email."),
_ => print(format!("Note: You have {email_count} unread emails.")),
PluralCategory::One => println!("Note: You have one unread email."),
_ => println!("Note: You have {email_count} unread emails."),
}
}

Expand Down
10 changes: 4 additions & 6 deletions components/icu/src/datagen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ icu_registry::registry!(cb);
///
/// ```no_run
/// # use icu_provider::DataMarker;
/// # use std::path::Path;
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// assert_eq!(
/// icu::markers_for_bin("target/release/my-app")?,
/// icu::markers_for_bin(Path::new("target/release/my-app"))?,
/// std::collections::HashSet::from_iter([
/// icu::list::provider::AndListV2Marker::INFO,
/// icu::list::provider::OrListV2Marker::INFO,
Expand All @@ -82,11 +83,8 @@ icu_registry::registry!(cb);
/// # Ok(())
/// # }
/// ```
pub fn markers_for_bin<P: AsRef<Path>>(path: P) -> Result<HashSet<DataMarkerInfo>, DataError> {
let file = std::fs::read(path.as_ref())?;
let file = file.as_slice();

markers_for_bin_inner(file)
pub fn markers_for_bin(path: &Path) -> Result<HashSet<DataMarkerInfo>, DataError> {
markers_for_bin_inner(&std::fs::read(path)?)
}

#[test]
Expand Down
4 changes: 3 additions & 1 deletion ffi/capi/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ pub mod ffi {
Ok(Box::new(convert_buffer_provider(
icu_provider_fs::FsDataProvider::try_new(
// In the future we can start using OsString APIs to support non-utf8 paths
core::str::from_utf8(path).map_err(|_| ICU4XDataError::Io)?,
core::str::from_utf8(path)
.map_err(|_| ICU4XDataError::Io)?
.into(),
)?,
)))
}
Expand Down
13 changes: 5 additions & 8 deletions provider/baked/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ use std::collections::HashSet;
use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Mutex;

Expand Down Expand Up @@ -208,12 +209,8 @@ impl BakedExporter {
})
}

fn write_to_file<P: AsRef<std::path::Path>>(
&self,
relative_path: P,
data: TokenStream,
) -> Result<(), DataError> {
let path = self.mod_directory.join(&relative_path);
fn write_to_file(&self, relative_path: &Path, data: TokenStream) -> Result<(), DataError> {
let path = self.mod_directory.join(relative_path);

let mut formatted = if self.pretty {
use std::process::{Command, Stdio};
Expand Down Expand Up @@ -323,7 +320,7 @@ impl BakedExporter {
let maybe_msrv = maybe_msrv();

self.write_to_file(
PathBuf::from(format!("{ident}.rs.data")),
Path::new(&format!("{ident}.rs.data")),
quote! {
#[doc = #doc]
/// hardcoded in this file. This allows the struct to be used with
Expand Down Expand Up @@ -599,7 +596,7 @@ impl DataExporter for BakedExporter {

// mod.rs is the interface for built-in data. It exposes one macro per marker.
self.write_to_file(
PathBuf::from("mod.rs"),
Path::new("mod.rs"),
quote! {
#(
include!(#file_paths);
Expand Down
111 changes: 110 additions & 1 deletion provider/bikeshed/data/debug/units/essentials@1/long/ar-EG.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 36f0a97

Please sign in to comment.