From a7754c14ae324130a8319f17705add8731d1d1dc Mon Sep 17 00:00:00 2001 From: clement Date: Sat, 4 May 2024 06:17:40 +0300 Subject: [PATCH] Export the types in a prelude module. --- README.md | 4 ++-- src/lib.rs | 6 ++++-- src/options.rs | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a8d1cc5..fbb79c9 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ apexcharts-rs = "0.1.3" and then in your code: ```rust -use apexcharts_rs::ApexCharts; +use apexcharts_rs::ApexChart; fn main() { let options = r#" @@ -30,7 +30,7 @@ fn main() { } "#; let options = ChartOptions(String::from(options)); - let chart = ApexCharts::new(&options.into()); + let chart = ApexChart::new(&options.into()); chart.render("chart_el_id"); } ``` diff --git a/src/lib.rs b/src/lib.rs index 650ae31..93ba0ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,5 +3,7 @@ mod options; mod bindings; -pub use crate::bindings::ApexChart; -pub use crate::options::{ChartOptions, ChartType, ChartSeries, SeriesData}; +pub mod prelude { + pub use crate::bindings::ApexChart; + pub use crate::options::{ChartOptions, ChartType, ChartSeries, SeriesData}; +} diff --git a/src/options.rs b/src/options.rs index 5f9d951..d3294c6 100644 --- a/src/options.rs +++ b/src/options.rs @@ -205,7 +205,7 @@ impl From for JsValue { #[cfg(test)] mod tests { use serde_json::Value; - use crate::{ChartOptions}; + use crate::prelude::{ChartOptions, ChartType}; const OPTIONS_STR: &str = r#" { @@ -229,7 +229,7 @@ mod tests { #[test] pub fn test_setting_chart_type() { let options = ChartOptions::from_string(String::from(OPTIONS_STR)) - .set_chart_type(crate::ChartType::Bar); + .set_chart_type(ChartType::Bar); let new_options = serde_json::from_str::(r#" { "chart": {