Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring icu-data-provider crate. #198

Merged
merged 5 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

30 changes: 9 additions & 21 deletions components/data-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,16 @@ 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"
smallstr = { version = "0.2", features = ["serde"] }
downcast-rs = "1.2"
serde = { version = "1.0", features = ["derive"] }

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

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

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

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

[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 {
sffc marked this conversation as resolved.
Show resolved Hide resolved
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