Skip to content

Commit

Permalink
data load
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Nov 13, 2024
1 parent 2851854 commit d96cdbd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tutorials/data_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,20 @@ where
}
}

// Load some en-US data as a base. Baked is the provider for icu::decimal's builtin
// "compiled data" that it ships by default.
let data = icu::decimal::provider::Baked
.load(DataRequest {
id: DataIdentifierBorrowed::for_locale(&locale!("en-US").into()),
..Default::default()
})
.unwrap()
.payload;

// Make a wrapped provider that modifies Swiss data requests
let provider = CustomDecimalSymbolsProvider(
FixedProvider::<DecimalSymbolsV1Marker>::new_default()
// Make a simple data provider that provides the loaded en-US data unconditionally
FixedProvider::<DecimalSymbolsV1Marker>::from_payload(data)
);

let formatter = FixedDecimalFormatter::try_new_unstable(
Expand Down

0 comments on commit d96cdbd

Please sign in to comment.