Skip to content

Commit

Permalink
lint: clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yisibl committed Aug 6, 2023
1 parent d94e43d commit 6768976
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
6 changes: 6 additions & 0 deletions js-binding.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* tslint:disable */
/* eslint-disable */
/* prettier-ignore */

/* auto-generated by NAPI-RS */

const { existsSync, readFileSync } = require('fs')
const { join } = require('path')

Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum Error {
#[cfg(not(target_arch = "wasm32"))]
impl From<Error> for napi::Error {
fn from(e: Error) -> Self {
napi::Error::from_reason(format!("{}", e))
napi::Error::from_reason(format!("{e}"))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl Resvg {
Either::A(a) => usvg::Tree::from_str(a.as_str(), &opts),
Either::B(b) => usvg::Tree::from_data(b.as_ref(), &opts),
}
.map_err(|e| napi::Error::from_reason(format!("{}", e)))?;
.map_err(|e| napi::Error::from_reason(format!("{e}")))?;
tree.convert_text(&fontdb);
Ok(Resvg { tree, js_options })
}
Expand Down Expand Up @@ -627,7 +627,7 @@ impl Task for AsyncRenderer {

fn compute(&mut self) -> Result<Self::Output, NapiError> {
let resvg = Resvg::new_inner(&self.svg, self.options.clone())?;
Ok(resvg.render()?)
resvg.render()
}

fn resolve(
Expand Down
13 changes: 5 additions & 8 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ pub(crate) trait ResvgReadable {

impl<'a> ResvgReadable for &'a str {
fn load(&self, options: &usvg::Options) -> Result<usvg::Tree, usvg::Error> {
usvg::Tree::from_str(&self, &options)
usvg::Tree::from_str(self, options)
}
}

impl<'a> ResvgReadable for &'a [u8] {
fn load(&self, options: &usvg::Options) -> Result<usvg::Tree, usvg::Error> {
usvg::Tree::from_data(self, &options)
usvg::Tree::from_data(self, options)
}
}

Expand Down Expand Up @@ -308,8 +308,7 @@ where
1 => Ok(usvg::ShapeRendering::CrispEdges),
2 => Ok(usvg::ShapeRendering::GeometricPrecision),
n => Err(serde::de::Error::custom(format_args!(
"Invalid ShapeRendering value: {}. Must be these numbers: 0 (OptimizeSpeed), 1 (CrispEdges), or 2 (GeometricPrecision).",
n
"Invalid ShapeRendering value: {n}. Must be these numbers: 0 (OptimizeSpeed), 1 (CrispEdges), or 2 (GeometricPrecision)."
))),
}
}
Expand All @@ -324,8 +323,7 @@ where
1 => Ok(usvg::TextRendering::OptimizeLegibility),
2 => Ok(usvg::TextRendering::GeometricPrecision),
n => Err(serde::de::Error::custom(format_args!(
"Invalid TextRendering value: {}. Must be these numbers: 0 (OptimizeSpeed), 1 (OptimizeLegibility), or 2 (GeometricPrecision).",
n
"Invalid TextRendering value: {n}. Must be these numbers: 0 (OptimizeSpeed), 1 (OptimizeLegibility), or 2 (GeometricPrecision)."
))),
}
}
Expand All @@ -339,8 +337,7 @@ where
0 => Ok(usvg::ImageRendering::OptimizeQuality),
1 => Ok(usvg::ImageRendering::OptimizeSpeed),
n => Err(serde::de::Error::custom(format_args!(
"Invalid ImageRendering value: {}. Must be these numbers: 0 (OptimizeQuality) or 1 (OptimizeSpeed).",
n
"Invalid ImageRendering value: {n}. Must be these numbers: 0 (OptimizeQuality) or 1 (OptimizeSpeed)."
))),
}
}
Expand Down
6 changes: 4 additions & 2 deletions wasm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,18 @@ export type SystemFontsOptions = {
*/
export declare const initWasm: (module_or_path: Promise<InitInput> | InitInput) => Promise<void>;
export declare const Resvg: {
new (svg: Uint8Array | string, options?: ResvgRenderOptions | undefined): {
new (svg: Uint8Array | string, options?: ResvgRenderOptions): {
free(): void;
render(): RenderedImage;
toString(): string;
innerBBox(): BBox | undefined;
getBBox(): BBox | undefined;
cropByBBox(bbox: BBox): void;
imagesToResolve(): Array<string>;
imagesToResolve(): any[];
resolveImage(href: string, buffer: Uint8Array): void;
readonly height: number;
readonly width: number;
};
};

export {};

1 comment on commit 6768976

@vercel
Copy link

@vercel vercel bot commented on 6768976 Aug 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

resvg-js – ./

resvg-js-git-main-yisibl.vercel.app
resvg-js.vercel.app
resvg-js-yisibl.vercel.app

Please sign in to comment.