Skip to content

Commit 0301259

Browse files
simplify path to str conversion (#283)
* simplify path to str conversion * save data as byte array --------- Signed-off-by: Andrei Gherghescu <[email protected]> Co-authored-by: Andrei Gherghescu <[email protected]>
1 parent cb35c37 commit 0301259

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

plotly_kaleido/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ impl Kaleido {
146146
dst.set_extension(format);
147147

148148
let image_data = self.convert(plotly_data, format, width, height, scale)?;
149-
let data: Vec<u8> = match format {
150-
"svg" | "eps" => image_data.as_bytes().to_vec(),
151-
_ => general_purpose::STANDARD.decode(image_data).unwrap(),
149+
let data = match format {
150+
"svg" | "eps" => image_data.as_bytes(),
151+
_ => &general_purpose::STANDARD.decode(image_data).unwrap(),
152152
};
153153
let mut file = File::create(dst.as_path())?;
154-
file.write_all(&data)?;
154+
file.write_all(data)?;
155155
file.flush()?;
156156

157157
Ok(())
@@ -183,12 +183,10 @@ impl Kaleido {
183183
height: usize,
184184
scale: f64,
185185
) -> Result<String, Box<dyn std::error::Error>> {
186-
let p = self.cmd_path.as_path();
187-
let p = p.to_str().unwrap();
188-
let p = String::from(p);
186+
let p = self.cmd_path.to_str().unwrap();
189187

190188
#[allow(clippy::zombie_processes)]
191-
let mut process = Command::new(p.as_str())
189+
let mut process = Command::new(p)
192190
.current_dir(self.cmd_path.parent().unwrap())
193191
.args([
194192
"plotly",

0 commit comments

Comments
 (0)