Skip to content

Commit 9891479

Browse files
Kijewskiandrei-ng
authored andcommitted
Less copying in template struct creation
1 parent b4ec4ac commit 9891479

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

plotly/src/plot.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{Configuration, Layout};
1515
#[template(path = "plot.html", escape = "none")]
1616
struct PlotTemplate<'a> {
1717
plot: &'a Plot,
18-
js_scripts: String,
18+
js_scripts: &'a str,
1919
}
2020

2121
#[derive(Template)]
@@ -24,7 +24,7 @@ struct PlotTemplate<'a> {
2424
struct StaticPlotTemplate<'a> {
2525
plot: &'a Plot,
2626
format: ImageFormat,
27-
js_scripts: String,
27+
js_scripts: &'a str,
2828
width: usize,
2929
height: usize,
3030
}
@@ -466,7 +466,7 @@ impl Plot {
466466
fn render(&self) -> String {
467467
let tmpl = PlotTemplate {
468468
plot: self,
469-
js_scripts: self.js_scripts.clone(),
469+
js_scripts: &self.js_scripts,
470470
};
471471
tmpl.render().unwrap()
472472
}
@@ -476,7 +476,7 @@ impl Plot {
476476
let tmpl = StaticPlotTemplate {
477477
plot: self,
478478
format,
479-
js_scripts: self.js_scripts.clone(),
479+
js_scripts: &self.js_scripts,
480480
width,
481481
height,
482482
};

0 commit comments

Comments
 (0)