Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed Sep 17, 2023
1 parent a5262d3 commit 3f91134
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
default = []
javascript = ["specta/typescript"]
javascript = ["specta/javascript"]
typescript = ["specta/typescript"]

[dependencies]
Expand Down Expand Up @@ -48,4 +48,4 @@ serde = "1.0.188"
tauri = "1.4.1"

[patch.crates-io]
specta = { git = "https://github.com/oscartbeaumont/specta", rev = "93dc916d51fe40be7b75e87a03100e7648168f5e" }
specta = { git = "https://github.com/oscartbeaumont/specta", rev = "efdd024fd1ab2a569ffe9d7fc484c419eb6ef9c5" }
2 changes: 1 addition & 1 deletion examples/custom-plugin/plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
.invoke_handler(plugin_utils.invoke_handler)
.setup(move |app| {
let app = app.clone();
(plugin_utils.setup)(&app.clone());
(plugin_utils.setup)(&app);

std::thread::spawn(move || loop {
RandomNumber(rand::random()).emit_all(&app).unwrap();
Expand Down
10 changes: 5 additions & 5 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl EventRegistry {
);
}

pub fn get_or_manage<'a, R: Runtime>(handle: &'a impl Manager<R>) -> tauri::State<'a, Self> {
pub fn get_or_manage<R: Runtime>(handle: &impl Manager<R>) -> tauri::State<'_, Self> {
if handle.try_state::<Self>().is_none() {
handle.manage(Self::default());
}
Expand Down Expand Up @@ -146,7 +146,7 @@ pub trait Event: Type + NamedType {
{
let meta = get_meta!(handle);

handle.listen_global(&meta.wrap_with_plugin(Self::NAME), make_handler!(handler))
handle.listen_global(meta.wrap_with_plugin(Self::NAME), make_handler!(handler))
}

fn once_global<F, R: Runtime>(handle: &impl Manager<R>, handler: F) -> EventHandler
Expand All @@ -156,7 +156,7 @@ pub trait Event: Type + NamedType {
{
let meta = get_meta!(handle);

handle.once_global(&meta.wrap_with_plugin(Self::NAME), make_handler!(handler))
handle.once_global(meta.wrap_with_plugin(Self::NAME), make_handler!(handler))
}

// Window functions
Expand Down Expand Up @@ -198,7 +198,7 @@ pub trait Event: Type + NamedType {
{
let meta = get_meta!(window);

window.listen(&meta.wrap_with_plugin(Self::NAME), make_handler!(handler))
window.listen(meta.wrap_with_plugin(Self::NAME), make_handler!(handler))
}

fn once<F>(window: &Window<impl Runtime>, handler: F) -> EventHandler
Expand All @@ -208,7 +208,7 @@ pub trait Event: Type + NamedType {
{
let meta = get_meta!(window);

window.once(&meta.wrap_with_plugin(Self::NAME), make_handler!(handler))
window.once(meta.wrap_with_plugin(Self::NAME), make_handler!(handler))
}
}

Expand Down
14 changes: 6 additions & 8 deletions src/js.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use crate::{js_ts, *};
use crate::*;
use heck::ToLowerCamelCase;
use indoc::formatdoc;
use specta::{
functions::FunctionDataType,
js,
ts::{self, js_doc, ExportError},
TypeMap,
js::{self, ExportError},
};
use tauri::Runtime;

Expand Down Expand Up @@ -43,7 +41,7 @@ impl ExportLanguage for Language {
.into_iter()
.chain(function.docs.iter().map(|s| s.to_string()))
.chain(function.args.iter().flat_map(|(name, typ)| {
ts::datatype(&cfg.inner, typ, type_map).map(|typ| {
js::datatype(&cfg.inner, typ, type_map).map(|typ| {
let name = name.to_lower_camel_case();

format!("@param {{ {typ} }} {name}")
Expand All @@ -53,7 +51,7 @@ impl ExportLanguage for Language {
.map(Into::into)
.collect::<Vec<_>>();

js_doc(&vec)
js::js_doc(&vec)
};

Ok(js_ts::function(
Expand Down Expand Up @@ -86,7 +84,7 @@ impl ExportLanguage for Language {

let (events_types, events_map) = js_ts::events_data(events, cfg, type_map)?;

let events = js_doc(
let events = js::js_doc(
&[].into_iter()
.chain(["@type {typeof __makeEvents__<{".to_string()])
.chain(events_types)
Expand Down Expand Up @@ -115,7 +113,7 @@ impl ExportLanguage for Language {
let dependant_types = type_map
.values()
.filter_map(|v| v.as_ref())
.map(|v| js::typedef_named_datatype(&cfg.inner, &v, type_map))
.map(|v| js::typedef_named_datatype(&cfg.inner, v, type_map))
.collect::<Result<Vec<_>, _>>()
.map(|v| v.join("\n"))?;

Expand Down

0 comments on commit 3f91134

Please sign in to comment.