Skip to content

Commit

Permalink
Clippy fixes + Bump up version
Browse files Browse the repository at this point in the history
  • Loading branch information
geofmureithi committed Oct 1, 2022
1 parent 7ece186 commit cdd1dc1
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 29 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hirola"
version = "0.2.0-beta.1"
version = "0.2.0"
authors = ["Geoffrey Mureithi <[email protected]>"]
description = "Hirola is an un-opinionated web framework that is focused on simplicity and predictability"
repository = "https://github.com/geofmureithi/hirola"
Expand All @@ -11,9 +11,9 @@ keywords = ["wasm", "html", "dom", "web"]
edition = "2021"

[dependencies]
hirola-core = { path = "crates/hirola-core", version = "0.2.0-beta.1" }
hirola-macros = { path = "crates/hirola-macros", version = "0.2.0-beta.1" }
hirola-form = { path = "crates/hirola-form", version = "0.2.0-beta.1", optional = true }
hirola-core = { path = "crates/hirola-core", version = "0.2.0" }
hirola-macros = { path = "crates/hirola-macros", version = "0.2.0" }
hirola-form = { path = "crates/hirola-form", version = "0.2.0", optional = true }


[features]
Expand Down
4 changes: 2 additions & 2 deletions crates/hirola-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hirola-core"
version = "0.2.0-beta.1"
version = "0.2.0"
authors = ["Geoffrey Mureithi <[email protected]>"]
edition = "2021"
description = "An html library for building client side webapps"
Expand All @@ -18,7 +18,7 @@ chrono = { version = "0.4", features = ["wasmbind"] }
anyhow = "1.0"
thiserror = "1.0"
html-escape = { version = "0.2.7", optional = true }
hirola-macros = { path = "../hirola-macros", version = "0.2.0-beta.1" }
hirola-macros = { path = "../hirola-macros", version = "0.2.0" }
ref-cast = "1.0"
serde = { version = "1.0", optional = true }
wasm-bindgen = { version = "0.2", optional = true }
Expand Down
11 changes: 6 additions & 5 deletions crates/hirola-core/src/callback.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::prelude::DomNode;

pub trait StateReduce<T> {
fn mut_callback<F, E>(&self, f: F) -> Box<dyn Fn(E) -> ()>
fn mut_callback<F, E>(&self, f: F) -> Box<dyn Fn(E)>
where
F: Fn(&T, E) -> T + 'static;
}
Expand All @@ -22,18 +22,19 @@ pub trait Mixin {

impl<T> Mixin for T
where
T: Fn(DomNode) -> (),
T: Fn(DomNode),
{
fn mixin(&self, _ns: &str, node: DomNode) -> Result<(), MixinError> {
Ok((&self)(node))
(&self)(node);
Ok(())
}
}

pub trait State: Clone {
// Get a callback that allows interacting with state
fn callback<F, E>(&self, f: F) -> Box<dyn Fn(E) -> ()>
fn callback<F, E>(&self, f: F) -> Box<dyn Fn(E)>
where
F: Fn(&Self, E) -> () + 'static,
F: Fn(&Self, E) + 'static,
Self: 'static,
{
let state = self.clone();
Expand Down
9 changes: 5 additions & 4 deletions crates/hirola-core/src/mixins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ use crate::{
pub fn rhtml<'a>(text: &'a str) -> Box<dyn Fn(DomNode) -> () + 'a> {
let cb = move |node: DomNode| {
let element = node.unchecked_into::<Element>();
element.set_inner_html(&format!("{text}"));
element.set_inner_html(text);
};
Box::new(cb)
}

/// A mixin that allows adding nonsignal text
pub fn rtext<'a, D: Display>(text: &'a D) -> Box<dyn Fn(DomNode) -> () + 'a> {
pub fn rtext<'a, D: Display>(text: &'a D) -> Box<dyn Fn(DomNode) + 'a> {
let cb = move |node: DomNode| {
let element = node.unchecked_into::<Element>();
element.set_text_content(Some(&format!("{text}")));
Expand All @@ -82,7 +82,7 @@ pub fn rtext<'a, D: Display>(text: &'a D) -> Box<dyn Fn(DomNode) -> () + 'a> {
}

/// Mixin that adds text to a dom node
pub fn text<T: Display>(text: &Signal<T>) -> Box<dyn Fn(DomNode) -> ()> {
pub fn text<T: Display>(text: &Signal<T>) -> Box<dyn Fn(DomNode)> {
let signal = text.clone();
let cb = move |node: DomNode| {
let element = node.unchecked_into::<Element>();
Expand All @@ -96,7 +96,7 @@ pub fn text<T: Display>(text: &Signal<T>) -> Box<dyn Fn(DomNode) -> ()> {
}

/// Mixin that adds text to a dom node
pub fn show(shown: &Signal<bool>) -> Box<dyn Fn(DomNode) -> ()> {
pub fn show(shown: &Signal<bool>) -> Box<dyn Fn(DomNode)> {
let signal = shown.clone();
let cb = move |node: DomNode| {
let element = node.unchecked_into::<HtmlElement>();
Expand Down Expand Up @@ -158,6 +158,7 @@ where
/// Two way binding for input and signals
pub mod model {
use super::*;
/// Bind a [HtmlInputElement] to a [Signal<T>]
pub fn input<T>(s: &Signal<T>) -> Model<HtmlInputElement, T> {
Model(s.clone(), PhantomData)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hirola-core/src/reactive/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl<T: 'static> Signal<T> {

impl<T> StateReduce<T> for Signal<T> {
/// Sets the return value
fn mut_callback<F, E>(&self, f: F) -> Box<dyn Fn(E) -> ()>
fn mut_callback<F, E>(&self, f: F) -> Box<dyn Fn(E)>
where
F: Fn(&T, E) -> T + 'static,
{
Expand Down
4 changes: 2 additions & 2 deletions crates/hirola-form/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hirola-form"
version = "0.2.0-beta.1"
version = "0.2.0"
edition = "2021"
description = "Form mixins and utilities for hirola"
repository = "https://github.com/geofmureithi/hirola"
Expand All @@ -12,7 +12,7 @@ keywords = ["wasm", "html", "form", "web"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
hirola-core = { path = "../hirola-core", version = "0.2.0-beta.1", features=["serde"] }
hirola-core = { path = "../hirola-core", version = "0.2.0", features=["serde"] }
wasm-bindgen = {version = "0.2", features= ["serde-serialize"]}
validator = "0.10"
validator_derive = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion crates/hirola-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hirola-macros"
version = "0.2.0-beta.1"
version = "0.2.0"
authors = ["Geoffrey Mureithi <[email protected]>"]
edition = "2021"
description = "Hirola is an un-opinionated web framework that is focused on simplicity and predictability"
Expand Down
4 changes: 2 additions & 2 deletions crates/hirola-macros/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ pub fn create_function_component(f: syn::ItemFn) -> TokenStream {
let block = f.block;
let vis = f.vis;

let inputs_block = if inputs.len() > 0 {
let inputs_block = if !inputs.is_empty() {
let input_names: Vec<_> = inputs.iter().collect();

quote!({ #(#vis #input_names),* })
} else {
quote!(;)
};

let inputs_reading = if inputs.len() == 0 {
let inputs_reading = if inputs.is_empty() {
quote!()
} else {
let input_names: Vec<_> = inputs
Expand Down
8 changes: 4 additions & 4 deletions crates/hirola-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ fn node_to_tokens(node: Node) -> TokenStream {
let name = node.name_as_string();

if let Some(name) = name {
if &name[0..1].to_lowercase() == &name[0..1] {
if name[0..1].to_lowercase() == name[0..1] {
let attributes = node
.attributes
.iter()
.map(|attribute| attribute_to_tokens(attribute));
.map(attribute_to_tokens);

let children_tokens = children_to_tokens(node.children);

Expand Down Expand Up @@ -76,7 +76,7 @@ fn node_to_tokens(node: Node) -> TokenStream {
None => quote! {},
})
.collect::<Vec<TokenStream>>();
if node.children.len() > 0 {
if !node.children.is_empty() {
let children_tokens = children_to_tokens(node.children);
attributes.extend(vec![quote! {
children: {
Expand All @@ -87,7 +87,7 @@ fn node_to_tokens(node: Node) -> TokenStream {
}]);
}

let quoted = if attributes.len() == 0 {
let quoted = if attributes.is_empty() {
quote!({&#fnname })
} else {
quote!({ &#fnname {#(#attributes),*} })
Expand Down

0 comments on commit cdd1dc1

Please sign in to comment.