Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Jun 11, 2024
1 parent 68bac0b commit bded087
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion provider/adapters/src/fallback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use icu_provider::prelude::*;
/// langid!("ja").into(),
/// );
/// assert_eq!(
/// response.payload.unwrap().get().message,
/// response.payload.get().message,
/// "こんにちは世界",
/// );
/// ```
Expand Down
2 changes: 1 addition & 1 deletion provider/adapters/src/fork/predicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl ForkByErrorPredicate for MissingDataMarkerPredicate {
/// })
/// .expect("Loading should succeed");
///
/// assert_eq!("Salut, lume", romanian_hello_world.payload..get().message);
/// assert_eq!("Salut, lume", romanian_hello_world.payload.get().message);
///
/// // We should not be able to load "en" data because it is not in the provider:
///
Expand Down
18 changes: 8 additions & 10 deletions tutorials/data_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,14 @@ where
#[inline]
fn load(&self, req: DataRequest) -> Result<DataResponse<M>, DataError> {
let mut res = self.0.load(req)?;
if let Some(mut generic_payload) = res.payload.as_mut() {
// Cast from `DataPayload<M>` to `DataPayload<DecimalSymbolsV1Marker>`
let mut any_payload = generic_payload as &mut dyn Any;
if let Some(mut decimal_payload) = any_payload.downcast_mut::<DataPayload<DecimalSymbolsV1Marker>>() {
if req.locale.region() == Some(region!("CH")) {
decimal_payload.with_mut(|data| {
// Change the grouping separator for all Swiss locales to '🐮'
data.grouping_separator = Cow::Borrowed("🐮");
});
}
// Cast from `DataPayload<M>` to `DataPayload<DecimalSymbolsV1Marker>`
let mut any_payload = (&mut res.payload) as &mut dyn Any;
if let Some(mut decimal_payload) = any_payload.downcast_mut::<DataPayload<DecimalSymbolsV1Marker>>() {
if req.locale.region() == Some(region!("CH")) {
decimal_payload.with_mut(|data| {
// Change the grouping separator for all Swiss locales to '🐮'
data.grouping_separator = Cow::Borrowed("🐮");
});
}
}
Ok(res)
Expand Down

0 comments on commit bded087

Please sign in to comment.