Skip to content

Commit

Permalink
Refactoring icu-data-provider crate.
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Aug 7, 2020
1 parent 9a296e8 commit 2155838
Show file tree
Hide file tree
Showing 22 changed files with 1,083 additions and 521 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

members = [
"components/data-provider",
"components/data-provider-json",
"components/icu",
"components/icu4x",
"components/uniset",
Expand Down
45 changes: 0 additions & 45 deletions components/data-provider-json/Cargo.toml

This file was deleted.

11 changes: 0 additions & 11 deletions components/data-provider-json/README.md

This file was deleted.

86 changes: 0 additions & 86 deletions components/data-provider-json/src/lib.rs

This file was deleted.

15 changes: 0 additions & 15 deletions components/data-provider-json/src/schema.rs

This file was deleted.

31 changes: 0 additions & 31 deletions components/data-provider-json/tests/test_file_io.rs

This file was deleted.

89 changes: 0 additions & 89 deletions components/data-provider-json/tests/test_no_std.rs

This file was deleted.

9 changes: 0 additions & 9 deletions components/data-provider-json/tests/testdata/all.json

This file was deleted.

22 changes: 9 additions & 13 deletions components/data-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,24 @@ include = [
]

[features]
default = ["std"]
std = ["serde/std", "no-std-compat/std"]
# Enable InvariantDataProvider, a locale-agnostic data provider.
invariant = []

[dependencies]
icu-locale = { path = "../locale" }
tinystr = "0.3"
erased-serde = "0.3"

[dependencies.smallstr]
version = "0.2.0"
default-features = false
version = "0.2"
features = ["serde"]

[dependencies.downcast-rs]
version = "1.1.1"

[dependencies.async-trait]
version = "0.1.30"
version = "1.1"

[dependencies.serde]
version = "1.0"
default-features = false
features = ["derive", "alloc"]
features = ["derive"]

[dependencies.no-std-compat]
version = "0.4.0"
features = ["alloc"]
[dev-dependencies]
serde_json = "1.0"
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use std::prelude::v1::*;

use downcast_rs::impl_downcast;
use downcast_rs::Downcast;
use std::fmt::Debug;

#[cfg(feature = "erased-serde")]
use erased_serde;

// Please do not to make this trait public, because it is easy to use incorrectly. It is fine as
// an internal auto-implemented trait.
pub(super) trait CloneableAny: Debug + Downcast {
pub(super) trait CloneableAny: Debug + Downcast + erased_serde::Serialize {
fn clone_into_box(&self) -> Box<dyn CloneableAny>;

fn as_serialize(&self) -> &dyn erased_serde::Serialize;
}

impl ToOwned for dyn CloneableAny {
Expand All @@ -19,10 +22,14 @@ impl ToOwned for dyn CloneableAny {
}

// Implement CloneableAny for all 'static types implementing Clone.
impl<S: 'static + Clone + Debug> CloneableAny for S {
impl<T: 'static + Clone + Debug + erased_serde::Serialize> CloneableAny for T {
fn clone_into_box(&self) -> Box<dyn CloneableAny> {
Box::new(self.clone())
}

fn as_serialize(&self) -> &dyn erased_serde::Serialize {
self
}
}

// Adds the Downcast methods to all 'static types implementing CloneableAny.
Expand Down
Loading

0 comments on commit 2155838

Please sign in to comment.