[Provider] Add a constructor or helper for silent DataRequestMetadata
C-data-infra
Robert suggested in a PR review on `unicode-org/icu4x#8082` that we should have a cleaner way to construct silent data requests:
> thought: we should really add a `DataRequestMetadata::silent()` constructor
Currently, to load data silently (without logging errors when speculative loads fail), we write:
```rust
let mut metadata = DataRequestMetadata::default();
metadata.silent = true;
provider.load(DataRequest { id, metadata })?;
```
It would be much cleaner and more idiomatic to support a helper constructor or a builder-like pattern:
```rust
provider.load(DataRequest {
id,
metadata: DataRequestMetadata::silent(),
})?;
```
We should add `DataRequestMetadata::silent()` or a similar constructor to `icu_provider`.
0 条评论