Skip to content

Commit

Permalink
move to closure
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Dec 13, 2024
1 parent 62acfbf commit 16911a0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ffi/capi/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ pub mod ffi {
}

impl DataProvider {
pub(crate) fn call_constructor<F, Ret>(
&self,
ctor: F,
) -> Result<Ret, icu_provider::DataError>
where
F: FnOnce(
&(dyn icu_provider::buf::BufferProvider + 'static),
) -> Result<Ret, icu_provider::DataError>,
{
match &self.0 {
DataProviderInner::Destroyed => Err(icu_provider::DataError::custom(
"This provider has been destroyed",
))?,
DataProviderInner::Buffer(ref buffer_provider) => ctor(buffer_provider),
}
}

/// Constructs an `FsDataProvider` and returns it as an [`DataProvider`].
/// Requires the `provider_fs` Cargo feature.
/// Not supported in WASM.
Expand Down

0 comments on commit 16911a0

Please sign in to comment.