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

Removed calls to unwrap() and expect() #35

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.0] - 2020-12-31
### Changed
- Removed calls to `.unwrap()` and `.expect()` in favor of returning `Result<T, Error>`


## [0.6.0] - 2020-07-25
### Added
Expand Down
8 changes: 4 additions & 4 deletions docs/book/src/fundamentals/ndarray_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ fn single_ndarray_trace(show: bool) {
let mut plot = Plot::new();
plot.add_trace(trace);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("single_ndarray_trace")));
println!("{}", plot.to_inline_html(Some("single_ndarray_trace")).unwrap());
}
```
<div id="single_ndarray_trace" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down Expand Up @@ -79,9 +79,9 @@ fn multiple_ndarray_traces_over_columns(show: bool) {
let mut plot = Plot::new();
plot.add_traces(traces);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("multiple_ndarray_traces_over_columns")));
println!("{}", plot.to_inline_html(Some("multiple_ndarray_traces_over_columns")).unwrap());
}
```
<div id="multiple_ndarray_traces_over_columns" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down
48 changes: 24 additions & 24 deletions docs/book/src/fundamentals/shapes.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ fn filled_area_chart(show: bool) {
plot.add_trace(trace1);
plot.add_trace(trace2);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("filled_area_chart")));
println!("{}", plot.to_inline_html(Some("filled_area_chart")).unwrap());
}
```
<div id="filled_area_chart" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down Expand Up @@ -106,13 +106,13 @@ fn vertical_and_horizontal_lines_positioned_relative_to_axes(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!(
"{}",
plot.to_inline_html(Some(
"vertical_and_horizontal_lines_positioned_relative_to_axes"
))
)).unwrap()
);
}
```
Expand Down Expand Up @@ -171,13 +171,13 @@ fn lines_positioned_relative_to_the_plot_and_to_the_axes(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!(
"{}",
plot.to_inline_html(Some(
"lines_positioned_relative_to_the_plot_and_to_the_axes"
))
)).unwrap()
);
}
```
Expand Down Expand Up @@ -247,11 +247,11 @@ fn creating_tangent_lines_with_shapes(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!(
"{}",
plot.to_inline_html(Some("creating_tangent_lines_with_shapes"))
plot.to_inline_html(Some("creating_tangent_lines_with_shapes")).unwrap()
);
}
```
Expand Down Expand Up @@ -308,11 +308,11 @@ fn rectangles_positioned_relative_to_the_axes(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!(
"{}",
plot.to_inline_html(Some("rectangles_positioned_relative_to_the_axes"))
plot.to_inline_html(Some("rectangles_positioned_relative_to_the_axes")).unwrap()
);
}
```
Expand Down Expand Up @@ -373,13 +373,13 @@ fn rectangle_positioned_relative_to_the_plot_and_to_the_axes(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!(
"{}",
plot.to_inline_html(Some(
"rectangle_positioned_relative_to_the_plot_and_to_the_axes"
))
)).unwrap()
);
}
```
Expand Down Expand Up @@ -471,13 +471,13 @@ fn highlighting_time_series_regions_with_rectangle_shapes(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!(
"{}",
plot.to_inline_html(Some(
"highlighting_time_series_regions_with_rectangle_shapes"
))
)).unwrap()
);
}
```
Expand Down Expand Up @@ -536,11 +536,11 @@ fn circles_positioned_relative_to_the_axes(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!(
"{}",
plot.to_inline_html(Some("circles_positioned_relative_to_the_axes"))
plot.to_inline_html(Some("circles_positioned_relative_to_the_axes")).unwrap()
);
}
```
Expand Down Expand Up @@ -669,13 +669,13 @@ fn highlighting_clusters_of_scatter_points_with_circle_shapes(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!(
"{}",
plot.to_inline_html(Some(
"highlighting_clusters_of_scatter_points_with_circle_shapes"
))
)).unwrap()
);
}
```
Expand Down Expand Up @@ -761,11 +761,11 @@ fn venn_diagram_with_circle_shapes(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!(
"{}",
plot.to_inline_html(Some("venn_diagram_with_circle_shapes"))
plot.to_inline_html(Some("venn_diagram_with_circle_shapes")).unwrap()
);
}
```
Expand Down Expand Up @@ -868,9 +868,9 @@ fn adding_shapes_to_subplots(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("adding_shapes_to_subplots")));
println!("{}", plot.to_inline_html(Some("adding_shapes_to_subplots")).unwrap());
}
```
<div id="adding_shapes_to_subplots" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down Expand Up @@ -947,9 +947,9 @@ fn svg_paths(show: bool) {

plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("svg_paths")));
println!("{}", plot.to_inline_html(Some("svg_paths")).unwrap());
}
```
<div id="svg_paths" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn line_and_scatter_plot() {
plot.add_trace(trace1);
plot.add_trace(trace2);
plot.add_trace(trace3);
plot.show();
plot.show().unwrap();
}

fn main() -> std::io::Result<()> {
Expand Down
18 changes: 9 additions & 9 deletions docs/book/src/recipes/basic_charts/bar_charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ The `to_inline_html` method is used to produce the html plot displayed in this p


## Basic Bar Chart
```rust
```rust
fn basic_bar_chart(show: bool) {
let animals = vec!["giraffes", "orangutans", "monkeys"];
let t = Bar::new(animals, vec![20, 14, 23]);
let mut plot = Plot::new();
plot.add_trace(t);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("basic_bar_chart")));
println!("{}", plot.to_inline_html(Some("basic_bar_chart")).unwrap());
}

```
Expand All @@ -43,7 +43,7 @@ var layout = {};
</script>

## Grouped Bar Chart
```rust
```rust
fn grouped_bar_chart(show: bool) {
let animals1 = vec!["giraffes", "orangutans", "monkeys"];
let trace1 = Bar::new(animals1, vec![20, 14, 23]).name("SF Zoo");
Expand All @@ -58,9 +58,9 @@ fn grouped_bar_chart(show: bool) {
plot.add_trace(trace2);
plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("grouped_bar_chart")));
println!("{}", plot.to_inline_html(Some("grouped_bar_chart")).unwrap());
}
```
<div id="grouped_bar_chart" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand All @@ -79,7 +79,7 @@ var layout = {"barmode":"group"};


## Stacked Bar Chart
```rust
```rust
fn stacked_bar_chart(show: bool) {
let animals1 = vec!["giraffes", "orangutans", "monkeys"];
let trace1 = Bar::new(animals1, vec![20, 14, 23]).name("SF Zoo");
Expand All @@ -94,9 +94,9 @@ fn stacked_bar_chart(show: bool) {
plot.add_trace(trace2);
plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("stacked_bar_chart")));
println!("{}", plot.to_inline_html(Some("stacked_bar_chart")).unwrap());
}
```
<div id="stacked_bar_chart" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down
24 changes: 12 additions & 12 deletions docs/book/src/recipes/basic_charts/line_charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ fn adding_names_to_line_and_scatter_plot(show: bool) {
plot.add_trace(trace3);
plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("adding_names_to_line_and_scatter_plot")));
println!("{}", plot.to_inline_html(Some("adding_names_to_line_and_scatter_plot")).unwrap());
}

```
Expand Down Expand Up @@ -81,9 +81,9 @@ fn line_and_scatter_styling(show: bool) {
plot.add_trace(trace3);
plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("line_and_scatter_styling")));
println!("{}", plot.to_inline_html(Some("line_and_scatter_styling")).unwrap());
}
```
<div id="line_and_scatter_styling" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down Expand Up @@ -122,9 +122,9 @@ fn styling_line_plot(show: bool) {
plot.add_trace(trace2);
plot.set_layout(layout);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("styling_line_plot")));
println!("{}", plot.to_inline_html(Some("styling_line_plot")).unwrap());
}
```
<div id="styling_line_plot" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down Expand Up @@ -185,9 +185,9 @@ fn line_shape_options_for_interpolation(show: bool) {
plot.add_trace(trace6);
plot.show_png(1024, 680);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("line_shape_options_for_interpolation")));
println!("{}", plot.to_inline_html(Some("line_shape_options_for_interpolation")).unwrap());
}
```
<div id="line_shape_options_for_interpolation" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down Expand Up @@ -254,9 +254,9 @@ fn line_dash(show: bool) {
plot.add_trace(trace5);
plot.add_trace(trace6);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("line_dash")));
println!("{}", plot.to_inline_html(Some("line_dash")).unwrap());
}
```
<div id="line_dash" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down Expand Up @@ -375,9 +375,9 @@ fn filled_lines(show: bool) {
plot.add_trace(trace5);
plot.add_trace(trace6);
if show {
plot.show();
plot.show().unwrap();
}
println!("{}", plot.to_inline_html(Some("filled_lines")));
println!("{}", plot.to_inline_html(Some("filled_lines")).unwrap());
}
```
<div id="filled_lines" class="plotly-graph-div" style="height:100%; width:100%;"></div>
Expand Down
Loading