summaryrefslogtreecommitdiffstats
path: root/vendor/icu_provider
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
commit2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch)
treed325add32978dbdc1db975a438b3a77d571b1ab8 /vendor/icu_provider
parentReleasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff)
downloadrustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz
rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/icu_provider')
-rw-r--r--vendor/icu_provider/.cargo-checksum.json2
-rw-r--r--vendor/icu_provider/Cargo.toml49
-rw-r--r--vendor/icu_provider/README.md2
-rw-r--r--vendor/icu_provider/src/any.rs60
-rw-r--r--vendor/icu_provider/src/buf.rs6
-rw-r--r--vendor/icu_provider/src/constructors.rs6
-rw-r--r--vendor/icu_provider/src/datagen/mod.rs2
-rw-r--r--vendor/icu_provider/src/error.rs12
-rw-r--r--vendor/icu_provider/src/hello_world.rs2
-rw-r--r--vendor/icu_provider/src/key.rs6
-rw-r--r--vendor/icu_provider/src/lib.rs2
-rw-r--r--vendor/icu_provider/src/request.rs40
-rw-r--r--vendor/icu_provider/src/response.rs10
-rw-r--r--vendor/icu_provider/src/serde/mod.rs18
14 files changed, 128 insertions, 89 deletions
diff --git a/vendor/icu_provider/.cargo-checksum.json b/vendor/icu_provider/.cargo-checksum.json
index fd85bb931..079ffc8f3 100644
--- a/vendor/icu_provider/.cargo-checksum.json
+++ b/vendor/icu_provider/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"2b5b03ef885db4858645deae855ec7347fda3b8b18ce326521d11dd5fa5e7f0d","LICENSE":"4ad7541d66a407234e2c84902124cef325c29f3e966353efdb800bedb8b8da21","README.md":"97887d230a6a85aa40110bf2bb9356a69b8762f64bdbf66d019f2cdf9f8fee0e","src/any.rs":"f347c91b6ad34d330d69e60f276716c595c32ca7abf591340ba659a54ba73415","src/buf.rs":"ed8d68fc8facae65294f648bca8dad2ad6e75fbea6250212a2f6fc8f1147a015","src/constructors.rs":"895162fc4f3ceeff9236a765b6caf41a343794af2fc0d9cc686487e6980ff111","src/data_provider.rs":"088fa10caeec785777366d543d8622ae4ac52fa0721de25281456d8346371e56","src/datagen/data_conversion.rs":"21c21bb300557f158f77155397a023e1eda22413d66ac0c4f8ce04184fd90b20","src/datagen/heap_measure.rs":"14f3224d071d0c9695720b53257a60da19c3355c4bff272f9a9e3c3a9711f27a","src/datagen/iter.rs":"6353ec6476596ae6dfd5aee5f3f420c3a1c1c6e71911fa7dae49e17564e1930f","src/datagen/mod.rs":"0ed8676ad23d5acf622b9b971195c44976eaa41320f86627ad2c3f506c064d4e","src/datagen/payload.rs":"d9b1e5ceb07bdadc01d200f712b556d37a325cfad8fc6c7c17ceecaab4ef57e2","src/dynutil.rs":"bff12a7000298a1f46c98bb66f94492a88f9111afb59e8accea6b83d95e83af2","src/error.rs":"d01b45212c1c3bf5e904c631a26d0c5f91802575e55675f73d3591a1d0da8f25","src/hello_world.rs":"57fd467793374d66ed05982ae04b72983b3d67744fa81cf7ddde1174d1d2e741","src/helpers.rs":"1712d389dfda2a9c2d5d973f212209ecb4a16f27998d893a2f1a4cf96cb44e10","src/key.rs":"286d271012fc2eb8b34bfa843a5783b4a3ce5a1e23a63234ca11a8f82f2c13cc","src/lib.rs":"26b72a010db444d339d3803b7e598842efe52fff97b56fb3c6ddf632fc70ecdc","src/marker.rs":"58d770fb28e696c33192b9ecc5a86e1dca01f206d62656b45787375d69168852","src/request.rs":"141b12da429c5dcc2577d0911a4b09b6d579d173510eac6d3cd997fd986020f4","src/response.rs":"71e078dabcc91c822c315ae89f499b7d9724b40addc89786320ca658979e2f6c","src/serde/borrow_de_utils.rs":"30936d0ac69a9edc1a4935dcf777f1c1161d3f8d8d3a997b80744cf6c62bc4b5","src/serde/mod.rs":"b7033686b2f6d72fbdab6388b65c29651fd3b6ac45a37981421dab03a73c5ef5"},"package":"2f911086e3c521a8a824d4f8bfd87769645ced2f07ff913b521c0d793be07100"} \ No newline at end of file
+{"files":{"Cargo.toml":"5eb9543e4ba0986f30237d8e026704143a75c1d197292f370294abd5a45bd10b","LICENSE":"4ad7541d66a407234e2c84902124cef325c29f3e966353efdb800bedb8b8da21","README.md":"bb2790cbf8d6109a07f4f0fe38aedfba0258637b1a28e67d35057eb57362fc41","src/any.rs":"7a6678e693e6090ebee04366dcf47a0449ce9006cca1f2ac429bd87eb9a0bbf2","src/buf.rs":"c1cb09ef992f6cefb65c8a0131d3f1e30332f093bd714429bba67e82fc3ee145","src/constructors.rs":"bbb8e0b82d8be54b6992d82df6738c20468e97af5910a22ceda437415ece9c13","src/data_provider.rs":"088fa10caeec785777366d543d8622ae4ac52fa0721de25281456d8346371e56","src/datagen/data_conversion.rs":"21c21bb300557f158f77155397a023e1eda22413d66ac0c4f8ce04184fd90b20","src/datagen/heap_measure.rs":"14f3224d071d0c9695720b53257a60da19c3355c4bff272f9a9e3c3a9711f27a","src/datagen/iter.rs":"6353ec6476596ae6dfd5aee5f3f420c3a1c1c6e71911fa7dae49e17564e1930f","src/datagen/mod.rs":"47e5b36432d27af3ff2662efceebe7dfb9b875f776e162dc547bb8ce2893e3a3","src/datagen/payload.rs":"d9b1e5ceb07bdadc01d200f712b556d37a325cfad8fc6c7c17ceecaab4ef57e2","src/dynutil.rs":"bff12a7000298a1f46c98bb66f94492a88f9111afb59e8accea6b83d95e83af2","src/error.rs":"c25cf6969feb7097edfc831a7d1aa6a3e3ba31c97e637f8f382bd3ec7905d5a7","src/hello_world.rs":"ff99a920ca8ef84d29129f1c8563fa96e963848532f9dbbddd02d634b8d6c0fb","src/helpers.rs":"1712d389dfda2a9c2d5d973f212209ecb4a16f27998d893a2f1a4cf96cb44e10","src/key.rs":"59d2d89107a24ee3f92f085715a1ba8c1222eced384969534fbcd43c68e2a658","src/lib.rs":"dcae8affb71e51095eab6180e08194e87a5aa6e339b8f3f18c4e1ce45a8c714a","src/marker.rs":"58d770fb28e696c33192b9ecc5a86e1dca01f206d62656b45787375d69168852","src/request.rs":"9ab23e38f941a4abc54be028888db6e787557088fc290d67b4f112db77c45521","src/response.rs":"9d93b42a1dda53f71195f1371c8a0a50755488af1fa20262fb703d60a6e1359e","src/serde/borrow_de_utils.rs":"30936d0ac69a9edc1a4935dcf777f1c1161d3f8d8d3a997b80744cf6c62bc4b5","src/serde/mod.rs":"a65937b6501a8106ae6036a7ba09977707b5268d2a6bdc3f2e43088610170da8"},"package":"a86816c97bc4e613086497f9479f63e120315e056763e8c4435604f98d21d82d"} \ No newline at end of file
diff --git a/vendor/icu_provider/Cargo.toml b/vendor/icu_provider/Cargo.toml
index 4ed67b0c0..84f561096 100644
--- a/vendor/icu_provider/Cargo.toml
+++ b/vendor/icu_provider/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2021"
name = "icu_provider"
-version = "1.0.1"
+version = "1.1.0"
authors = ["The ICU4X Project Developers"]
include = [
"src/**/*",
@@ -30,23 +30,18 @@ license = "Unicode-DFS-2016"
repository = "https://github.com/unicode-org/icu4x"
resolver = "2"
-[package.metadata.cargo-all-features]
-skip_optional_dependencies = true
-denylist = [
- "bench",
- "macros",
-]
-extra_features = ["serde"]
-
[package.metadata.docs.rs]
all-features = true
+[package.metadata.cargo-all-features]
+denylist = ["macros"]
+
[dependencies.bincode]
version = "1.3"
optional = true
[dependencies.databake]
-version = "0.1.0"
+version = "0.1.3"
features = ["derive"]
optional = true
@@ -65,10 +60,10 @@ optional = true
default-features = false
[dependencies.icu_locid]
-version = "1.0.0"
+version = "1.1.0"
[dependencies.icu_provider_macros]
-version = "1.0.0"
+version = "1.1.0"
optional = true
[dependencies.log]
@@ -100,53 +95,47 @@ version = "1.2.0"
default-features = false
[dependencies.writeable]
-version = "0.5"
+version = "0.5.1"
[dependencies.yoke]
-version = "0.6.2"
+version = "0.7.0"
features = ["derive"]
[dependencies.zerofrom]
-version = "0.1.0"
+version = "0.1.1"
features = ["derive"]
[dependencies.zerovec]
-version = "0.9"
+version = "0.9.2"
features = ["derive"]
[dev-dependencies.serde_json]
version = "1.0"
-[dev-dependencies.static_assertions]
-version = "1.1"
-
[features]
datagen = [
- "dhat",
+ "dep:dhat",
"serde",
- "erased-serde",
- "databake",
+ "dep:erased-serde",
+ "dep:databake",
"std",
- "serde_json",
"sync",
- "yoke/serde",
]
-default = []
deserialize_bincode_1 = [
"serde",
- "bincode",
+ "dep:bincode",
"std",
]
deserialize_json = [
"serde",
- "serde_json",
+ "dep:serde_json",
]
deserialize_postcard_1 = [
"serde",
- "postcard",
+ "dep:postcard",
]
-log_error_context = ["log"]
-macros = ["icu_provider_macros"]
+log_error_context = ["dep:log"]
+macros = ["dep:icu_provider_macros"]
serde = [
"dep:serde",
"yoke/serde",
diff --git a/vendor/icu_provider/README.md b/vendor/icu_provider/README.md
index 19d73a1a2..5692fa6b3 100644
--- a/vendor/icu_provider/README.md
+++ b/vendor/icu_provider/README.md
@@ -92,7 +92,7 @@ structs to borrow zero-copy data.
### Data generation API
-*This functionality is enabled with the "datagen" feature*
+*This functionality is enabled with the "datagen" Cargo feature*
The [`datagen`] module contains several APIs for data generation. See [`icu_datagen`] for the reference
data generation implementation.
diff --git a/vendor/icu_provider/src/any.rs b/vendor/icu_provider/src/any.rs
index 1c7a60435..989438c6b 100644
--- a/vendor/icu_provider/src/any.rs
+++ b/vendor/icu_provider/src/any.rs
@@ -18,7 +18,7 @@ use alloc::rc::Rc as SelectedRc;
use alloc::sync::Arc as SelectedRc;
/// A trait that allows to specify `Send + Sync` bounds that are only required when
-/// the `sync` feature is enabled. Without the feature, this is an empty bound.
+/// the `sync` Cargo feature is enabled. Without the Cargo feature, this is an empty bound.
#[cfg(feature = "sync")]
pub trait MaybeSendSync: Send + Sync {}
#[cfg(feature = "sync")]
@@ -115,6 +115,19 @@ impl AnyPayload {
}
}
+ /// Clones and then transforms a type-erased `AnyPayload` into a concrete `DataPayload<M>`.
+ pub fn downcast_cloned<M>(&self) -> Result<DataPayload<M>, DataError>
+ where
+ M: DataMarker + 'static,
+ // For the StructRef case:
+ M::Yokeable: ZeroFrom<'static, M::Yokeable>,
+ // For the PayloadRc case:
+ M::Yokeable: MaybeSendSync,
+ for<'a> YokeTraitHack<<M::Yokeable as Yokeable<'a>>::Output>: Clone,
+ {
+ self.clone().downcast()
+ }
+
/// Creates an `AnyPayload` from a static reference to a data struct.
///
/// # Examples
@@ -230,7 +243,7 @@ impl From<AnyResponse> for DataResponse<AnyMarker> {
}
impl AnyResponse {
- /// Transforms a type-erased `DataResponse<AnyMarker>` into a concrete `DataResponse<M>`.
+ /// Transforms a type-erased `AnyResponse` into a concrete `DataResponse<M>`.
#[inline]
pub fn downcast<M>(self) -> Result<DataResponse<M>, DataError>
where
@@ -244,6 +257,39 @@ impl AnyResponse {
payload: self.payload.map(|p| p.downcast()).transpose()?,
})
}
+
+ /// Clones and then transforms a type-erased `AnyResponse` into a concrete `DataResponse<M>`.
+ pub fn downcast_cloned<M>(&self) -> Result<DataResponse<M>, DataError>
+ where
+ M: DataMarker + 'static,
+ M::Yokeable: ZeroFrom<'static, M::Yokeable>,
+ M::Yokeable: MaybeSendSync,
+ for<'a> YokeTraitHack<<M::Yokeable as Yokeable<'a>>::Output>: Clone,
+ {
+ Ok(DataResponse {
+ metadata: self.metadata.clone(),
+ payload: self
+ .payload
+ .as_ref()
+ .map(|p| p.downcast_cloned())
+ .transpose()?,
+ })
+ }
+}
+
+impl<M> DataResponse<M>
+where
+ M: DataMarker + 'static,
+ M::Yokeable: MaybeSendSync,
+{
+ /// Moves the inner DataPayload to the heap (requiring an allocation) and returns it as an
+ /// erased `AnyResponse`.
+ pub fn wrap_into_any_response(self) -> AnyResponse {
+ AnyResponse {
+ metadata: self.metadata,
+ payload: self.payload.map(|p| p.wrap_into_any_payload()),
+ }
+ }
}
/// An object-safe data provider that returns data structs cast to `dyn Any` trait objects.
@@ -345,7 +391,10 @@ where
{
#[inline]
fn load(&self, req: DataRequest) -> Result<DataResponse<M>, DataError> {
- self.0.load_any(M::KEY, req)?.downcast()
+ self.0
+ .load_any(M::KEY, req)?
+ .downcast()
+ .map_err(|e| e.with_req(M::KEY, req))
}
}
@@ -359,7 +408,10 @@ where
{
#[inline]
fn load_data(&self, key: DataKey, req: DataRequest) -> Result<DataResponse<M>, DataError> {
- self.0.load_any(key, req)?.downcast()
+ self.0
+ .load_any(key, req)?
+ .downcast()
+ .map_err(|e| e.with_req(key, req))
}
}
diff --git a/vendor/icu_provider/src/buf.rs b/vendor/icu_provider/src/buf.rs
index 73bc0f165..796ad32f3 100644
--- a/vendor/icu_provider/src/buf.rs
+++ b/vendor/icu_provider/src/buf.rs
@@ -21,7 +21,11 @@ impl DataMarker for BufferMarker {
///
/// Generally, these bytes are expected to be deserializable with Serde. To get an object
/// implementing [`DataProvider`] via Serde, use [`as_deserializing()`], which requires
-/// enabling at least one of the Serde features.
+/// enabling at least one of the deserialization Cargo features:
+///
+/// - `deserialize_json`
+/// - `deserialize_postcard_1`
+/// - `deserialize_bincode_1`
///
/// Along with [`DataProvider`], this is one of the two foundational traits in this crate.
///
diff --git a/vendor/icu_provider/src/constructors.rs b/vendor/icu_provider/src/constructors.rs
index a9330c3f2..053da0320 100644
--- a/vendor/icu_provider/src/constructors.rs
+++ b/vendor/icu_provider/src/constructors.rs
@@ -54,7 +54,7 @@
//! 2. [`FsDataProvider`]
//! 3. [`ForkByKeyProvider`] between any of the above
//!
-//! Please note that you must enable the `"serde"` feature on each crate in which you use the
+//! Please note that you must enable the `"serde"` Cargo feature on each crate in which you use the
//! `*_with_buffer_provider` constructor.
//!
//! # Data Versioning Policy
@@ -78,8 +78,8 @@
//! Over FFI, there is only one data provider type: [`ICU4XDataProvider`]. Internally, it is an
//! `enum` between `dyn `[`AnyProvider`] and `dyn `[`BufferProvider`].
//!
-//! To control for code size, there are two features, `any_provider` and `buffer_provider`, that
-//! enable the corresponding items in the enum.
+//! To control for code size, there are two Cargo features, `any_provider` and `buffer_provider`,
+//! that enable the corresponding items in the enum.
//!
//! In Rust ICU4X, a similar buffer/any enum approach was not taken because:
//!
diff --git a/vendor/icu_provider/src/datagen/mod.rs b/vendor/icu_provider/src/datagen/mod.rs
index 5ede82275..e52a19c4d 100644
--- a/vendor/icu_provider/src/datagen/mod.rs
+++ b/vendor/icu_provider/src/datagen/mod.rs
@@ -6,7 +6,7 @@
//! via the `icu_datagen` reference crate. End users should not need to consume anything in
//! this module as a library unless defining new types that integrate with `icu_datagen`.
//!
-//! This module can be enabled with the `datagen` feature on `icu_provider`.
+//! This module can be enabled with the `datagen` Cargo feature on `icu_provider`.
mod data_conversion;
mod heap_measure;
diff --git a/vendor/icu_provider/src/error.rs b/vendor/icu_provider/src/error.rs
index 39bd1d0bb..05a48f9b7 100644
--- a/vendor/icu_provider/src/error.rs
+++ b/vendor/icu_provider/src/error.rs
@@ -64,8 +64,8 @@ pub enum DataErrorKind {
MissingSourceData,
/// An error indicating that the desired buffer format is not available. This usually
- /// means that a required feature was not enabled
- #[displaydoc("Unavailable buffer format: {0:?} (does icu_provider need to be compiled with an additional feature?)")]
+ /// means that a required Cargo feature was not enabled
+ #[displaydoc("Unavailable buffer format: {0:?} (does icu_provider need to be compiled with an additional Cargo feature?)")]
UnavailableBufferFormat(BufferFormat),
}
@@ -196,7 +196,7 @@ impl DataError {
/// Logs the data error with the given request, returning an error containing the resource key.
///
- /// If the "log_error_context" feature is enabled, this logs the whole request. Either way,
+ /// If the "log_error_context" Cargo feature is enabled, this logs the whole request. Either way,
/// it returns an error with the resource key portion of the request as context.
#[cfg_attr(not(feature = "log_error_context"), allow(unused_variables))]
pub fn with_req(self, key: DataKey, req: DataRequest) -> Self {
@@ -210,7 +210,7 @@ impl DataError {
/// Logs the data error with the given context, then return self.
///
- /// This does not modify the error, but if the "log_error_context" feature is enabled,
+ /// This does not modify the error, but if the "log_error_context" Cargo feature is enabled,
/// it will print out the context.
#[cfg(feature = "std")]
#[cfg_attr(not(feature = "log_error_context"), allow(unused_variables))]
@@ -222,7 +222,7 @@ impl DataError {
/// Logs the data error with the given context, then return self.
///
- /// This does not modify the error, but if the "log_error_context" feature is enabled,
+ /// This does not modify the error, but if the "log_error_context" Cargo feature is enabled,
/// it will print out the context.
#[cfg_attr(not(feature = "log_error_context"), allow(unused_variables))]
#[inline]
@@ -234,7 +234,7 @@ impl DataError {
/// Logs the data error with the given context, then return self.
///
- /// This does not modify the error, but if the "log_error_context" feature is enabled,
+ /// This does not modify the error, but if the "log_error_context" Cargo feature is enabled,
/// it will print out the context.
#[cfg_attr(not(feature = "log_error_context"), allow(unused_variables))]
#[inline]
diff --git a/vendor/icu_provider/src/hello_world.rs b/vendor/icu_provider/src/hello_world.rs
index 5fa671d84..7fd8289df 100644
--- a/vendor/icu_provider/src/hello_world.rs
+++ b/vendor/icu_provider/src/hello_world.rs
@@ -266,6 +266,8 @@ impl<'l> Writeable for FormattedHelloWorld<'l> {
}
}
+writeable::impl_display_with_writeable!(FormattedHelloWorld<'_>);
+
#[cfg(feature = "datagen")]
impl IterableDataProvider<HelloWorldV1Marker> for HelloWorldProvider {
fn supported_locales(&self) -> Result<Vec<DataLocale>, DataError> {
diff --git a/vendor/icu_provider/src/key.rs b/vendor/icu_provider/src/key.rs
index 2f55e4d46..d4d6905c9 100644
--- a/vendor/icu_provider/src/key.rs
+++ b/vendor/icu_provider/src/key.rs
@@ -140,11 +140,6 @@ impl DataKeyPath {
/// Gets the path as a static string slice.
#[inline]
pub const fn get(self) -> &'static str {
- /// core::slice::from_raw_parts(a, b) = core::mem::transmute((a, b)) hack
- /// ```compile_fail
- /// const unsafe fn canary() { core::slice::from_raw_parts(0 as *const u8, 0); }
- /// ```
- const _: () = ();
unsafe {
// Safe due to invariant that self.path is tagged correctly
core::str::from_utf8_unchecked(core::mem::transmute((
@@ -624,7 +619,6 @@ fn test_key_to_string() {
expected: "core/cardinal@65535",
},
] {
- assert_eq!(cas.expected, cas.key.to_string());
writeable::assert_writeable_eq!(&cas.key, cas.expected);
}
}
diff --git a/vendor/icu_provider/src/lib.rs b/vendor/icu_provider/src/lib.rs
index 594e872f4..7ee5b34e2 100644
--- a/vendor/icu_provider/src/lib.rs
+++ b/vendor/icu_provider/src/lib.rs
@@ -94,7 +94,7 @@
//!
//! ## Data generation API
//!
-//! *This functionality is enabled with the "datagen" feature*
+//! *This functionality is enabled with the "datagen" Cargo feature*
//!
//! The [`datagen`] module contains several APIs for data generation. See [`icu_datagen`] for the reference
//! data generation implementation.
diff --git a/vendor/icu_provider/src/request.rs b/vendor/icu_provider/src/request.rs
index 7f6bb5911..5f51f3a2c 100644
--- a/vendor/icu_provider/src/request.rs
+++ b/vendor/icu_provider/src/request.rs
@@ -53,11 +53,11 @@ pub struct DataRequestMetadata;
/// use icu_locid::locale;
/// use icu_provider::DataLocale;
///
-/// let locale1 = locale!("en-u-ca-buddhist");
-/// let data_locale = DataLocale::from(locale1);
-/// let locale2 = data_locale.into_locale();
+/// let locale = locale!("en-u-ca-buddhist");
+/// let data_locale = DataLocale::from(locale);
+/// let locale = data_locale.into_locale();
///
-/// assert_eq!(locale2.to_string(), "en-u-ca-buddhist");
+/// assert_eq!(locale, locale!("en-u-ca-buddhist"));
/// ```
///
/// You can alternatively create a [`DataLocale`] from a borrowed [`Locale`], which is more
@@ -81,18 +81,18 @@ pub struct DataRequestMetadata;
/// use icu_locid::langid;
/// use icu_provider::DataLocale;
///
-/// let langid1 = langid!("es-CA-valencia");
-/// let data_locale = DataLocale::from(langid1);
-/// let langid2 = data_locale.get_langid();
+/// let langid = langid!("es-CA-valencia");
+/// let data_locale = DataLocale::from(langid);
+/// let langid = data_locale.get_langid();
///
-/// assert_eq!(langid2.to_string(), "es-CA-valencia");
+/// assert_eq!(langid, langid!("es-CA-valencia"));
/// ```
///
/// [`DataLocale`] only supports `-u` keywords, to reflect the current state of CLDR data
/// lookup and fallback. This may change in the future.
///
/// ```
-/// use icu_locid::Locale;
+/// use icu_locid::{locale, Locale};
/// use icu_provider::DataLocale;
///
/// let locale = "hi-t-en-h0-hybrid-u-attr-ca-buddhist"
@@ -100,7 +100,7 @@ pub struct DataRequestMetadata;
/// .unwrap();
/// let data_locale = DataLocale::from(locale);
///
-/// assert_eq!(data_locale.to_string(), "hi-u-ca-buddhist");
+/// assert_eq!(data_locale.into_locale(), locale!("hi-u-ca-buddhist"));
/// ```
#[derive(PartialEq, Clone, Default, Eq, Hash)]
pub struct DataLocale {
@@ -225,7 +225,6 @@ impl DataLocale {
/// let b = ab[1];
/// assert!(a.cmp(b) == Ordering::Less);
/// let a_loc: DataLocale = a.parse::<Locale>().unwrap().into();
- /// assert_eq!(a, a_loc.to_string());
/// assert!(
/// a_loc.strict_cmp(a.as_bytes()) == Ordering::Equal,
/// "{} == {}",
@@ -239,7 +238,6 @@ impl DataLocale {
/// b
/// );
/// let b_loc: DataLocale = b.parse::<Locale>().unwrap().into();
- /// assert_eq!(b, b_loc.to_string());
/// assert!(
/// b_loc.strict_cmp(b.as_bytes()) == Ordering::Equal,
/// "{} == {}",
@@ -338,21 +336,20 @@ impl DataLocale {
///
/// ```
/// use icu_locid::{
- /// langid, subtags_language as language, subtags_region as region, Locale,
+ /// langid, locale, subtags_language as language, subtags_region as region,
+ /// Locale,
/// };
/// use icu_provider::prelude::*;
///
- /// let locale: Locale = "it-IT-u-ca-coptic".parse().expect("Valid BCP-47");
- /// let locale: DataLocale = locale.into();
+ /// let locale: DataLocale = locale!("it-IT-u-ca-coptic").into();
///
- /// assert_eq!(locale.to_string(), "it-IT-u-ca-coptic");
/// assert_eq!(locale.get_langid(), langid!("it-IT"));
/// assert_eq!(locale.language(), language!("it"));
/// assert_eq!(locale.script(), None);
/// assert_eq!(locale.region(), Some(region!("IT")));
///
/// let locale = locale.into_locale();
- /// assert_eq!(locale.to_string(), "it-IT-u-ca-coptic");
+ /// assert_eq!(locale, locale!("it-IT-u-ca-coptic"));
/// ```
pub fn into_locale(self) -> Locale {
let mut loc = Locale {
@@ -488,6 +485,8 @@ impl DataLocale {
#[test]
fn test_data_locale_to_string() {
+ use icu_locid::locale;
+
struct TestCase {
pub locale: DataLocale,
pub expected: &'static str,
@@ -499,15 +498,14 @@ fn test_data_locale_to_string() {
expected: "und",
},
TestCase {
- locale: "und-u-cu-gbp".parse::<Locale>().unwrap().into(),
+ locale: locale!("und-u-cu-gbp").into(),
expected: "und-u-cu-gbp",
},
TestCase {
- locale: "en-ZA-u-cu-gbp".parse::<Locale>().unwrap().into(),
+ locale: locale!("en-ZA-u-cu-gbp").into(),
expected: "en-ZA-u-cu-gbp",
},
] {
- assert_eq!(cas.expected, cas.locale.to_string());
- writeable::assert_writeable_eq!(&cas.locale, cas.expected);
+ writeable::assert_writeable_eq!(cas.locale, cas.expected);
}
}
diff --git a/vendor/icu_provider/src/response.rs b/vendor/icu_provider/src/response.rs
index 653d20a68..1ea6c8a76 100644
--- a/vendor/icu_provider/src/response.rs
+++ b/vendor/icu_provider/src/response.rs
@@ -51,10 +51,10 @@ pub struct DataResponseMetadata {
/// To transform a [`DataPayload`] to a different type backed by the same data store (cart), use
/// [`DataPayload::map_project()`] or one of its sister methods.
///
-/// # `sync` feature
+/// # Cargo feature: `sync`
///
/// By default, the payload uses non-concurrent reference counting internally, and hence is neither
-/// [`Sync`] nor [`Send`]; if these traits are required, the `sync` feature can be enabled.
+/// [`Sync`] nor [`Send`]; if these traits are required, the `sync` Cargo feature can be enabled.
///
/// # Examples
///
@@ -183,7 +183,7 @@ where
/// use std::borrow::Cow;
///
/// let local_struct = HelloWorldV1 {
- /// message: Cow::Owned("example".to_string()),
+ /// message: Cow::Owned("example".to_owned()),
/// };
///
/// let payload =
@@ -236,8 +236,8 @@ where
/// let mut payload =
/// DataPayload::<HelloWorldV1Marker>::from_static_str("Hello");
///
- /// let suffix = " World".to_string();
- /// payload.with_mut(move |s| s.message.to_mut().push_str(&suffix));
+ /// let suffix = " World";
+ /// payload.with_mut(move |s| s.message.to_mut().push_str(suffix));
///
/// assert_eq!("Hello World", payload.get().message);
/// ```
diff --git a/vendor/icu_provider/src/serde/mod.rs b/vendor/icu_provider/src/serde/mod.rs
index d32148f02..2e96b3cb3 100644
--- a/vendor/icu_provider/src/serde/mod.rs
+++ b/vendor/icu_provider/src/serde/mod.rs
@@ -94,7 +94,7 @@ impl DataPayload<BufferMarker> {
///
/// # Examples
///
- /// Requires the `deserialize_json` feature:
+ /// Requires the `deserialize_json` Cargo feature:
///
/// ```
/// use icu_provider::buf::BufferFormat;
@@ -136,16 +136,16 @@ where
{
fn load_data(&self, key: DataKey, req: DataRequest) -> Result<DataResponse<M>, DataError> {
let buffer_response = BufferProvider::load_buffer(self.0, key, req)?;
- let buffer_format = buffer_response
- .metadata
- .buffer_format
- .ok_or_else(|| DataError::custom("BufferProvider didn't set BufferFormat"))?;
+ let buffer_format = buffer_response.metadata.buffer_format.ok_or_else(|| {
+ DataError::custom("BufferProvider didn't set BufferFormat").with_req(key, req)
+ })?;
Ok(DataResponse {
metadata: buffer_response.metadata,
payload: buffer_response
.payload
.map(|p| p.into_deserialized(buffer_format))
- .transpose()?,
+ .transpose()
+ .map_err(|e| e.with_req(key, req))?,
})
}
}
@@ -165,21 +165,21 @@ where
}
}
-#[cfg(feature = "serde_json")]
+#[cfg(feature = "deserialize_json")]
impl From<serde_json::error::Error> for crate::DataError {
fn from(e: serde_json::error::Error) -> Self {
crate::DataError::custom("JSON deserialize").with_display_context(&e)
}
}
-#[cfg(feature = "bincode")]
+#[cfg(feature = "deserialize_bincode_1")]
impl From<bincode::Error> for crate::DataError {
fn from(e: bincode::Error) -> Self {
crate::DataError::custom("Bincode deserialize").with_display_context(&e)
}
}
-#[cfg(feature = "postcard")]
+#[cfg(feature = "deserialize_postcard_1")]
impl From<postcard::Error> for crate::DataError {
fn from(e: postcard::Error) -> Self {
crate::DataError::custom("Postcard deserialize").with_display_context(&e)