}
@@ -49,7 +49,7 @@ fn Hello(name: &str) -> impl View + '_ {
fn main() {
kobold::start(view! {
-
+
});
}
```
@@ -64,8 +64,8 @@ token stream, so the Rust compiler can tell you when you've made a mistake:
error[E0560]: struct `Hello` has no field named `nam`
--> examples/hello_world/src/main.rs:12:16
|
-12 |
- | ^^^ help: a field with a similar name exists: `name`
+12 |
+ | ^^^ help: there is a method with a similar name: `name`
```
You can even use [rust-analyzer](https://rust-analyzer.github.io/) to refactor component or field names,
@@ -80,7 +80,7 @@ their state:
use kobold::prelude::*;
#[component]
-fn Counter(init: u32) -> impl View {
+fn counter(init: u32) -> impl View {
stateful(init, |count| {
bind! { count:
// Create an event handler with access to `&mut u32`
@@ -100,7 +100,7 @@ fn Counter(init: u32) -> impl View {
fn main() {
kobold::start(view! {
-
+
});
}
```
@@ -109,7 +109,7 @@ The `stateful` function takes two parameters:
* State constructor that implements the `IntoState` trait. **Kobold** comes with default
implementations for most primitive types, so we can use `u32` here.
-* The anonymous render function that uses the constructed state, in our case its argument is `&Hook`.
+* The anonymous render closure that uses the constructed state, in our case its argument is `&Hook`.
The `Hook` here is a smart pointer to the state itself that allows non-mutable access to the
state. The `bind!` macro can be invoked for any `Hook` to create closures with `&mut` references to the
@@ -124,7 +124,7 @@ Use `#[component(?)]` syntax to set a component parameter as default:
```rust
// `code` will default to `200` if omitted
#[component(code?: 200)]
-fn Status(code: u32) -> impl View {
+fn status(code: u32) -> impl View {
view! {
"Status code was "{ code }
}
@@ -132,9 +132,9 @@ fn Status(code: u32) -> impl View {
view! {
// Status code was 200
-
+
// Status code was 404
-
+
}
```
@@ -151,7 +151,7 @@ inside an `if` or `match` expression, and wrap them in an enum making them the s
```rust
#[component(auto_branch)]
-fn Conditional(illuminatus: bool) -> impl View {
+fn conditional(illuminatus: bool) -> impl View {
if illuminatus {
view! {
"It was the year when they finally immanentized the Eschaton." }
} else {
@@ -167,11 +167,10 @@ For more details visit the [`branching` module documentation](https://docs.rs/ko
To render an iterator use the `for` keyword:
```rust
-// `ListIteratorExt` is included in the prelude
use kobold::prelude::*;
#[component]
-fn IterateNumbers(count: u32) -> impl View {
+fn iterate_numbers(count: u32) -> impl View {
view! {
{
@@ -195,7 +194,7 @@ state without unnecessary clones:
```rust
#[component]
-fn Users<'a>(names: &'a [&'a str]) -> impl View + 'a {
+fn users<'a>(names: &'a [&'a str]) -> impl View + 'a {
view! {
{
@@ -214,7 +213,7 @@ If you wish to capture children from parent `view!` invocation, simply change
use kobold::prelude::*;
#[component(children)]
-fn Header(children: impl View) -> impl View {
+fn header(children: impl View) -> impl View {
view! {
{ children }
}
@@ -222,7 +221,7 @@ fn Header(children: impl View) -> impl View {
fn main() {
kobold::start(view! {
- "Hello Kobold"
+ "Hello Kobold"!header>
});
}
```
@@ -234,7 +233,7 @@ use kobold::prelude::*;
// Capture children into the argument `n`
#[component(children: n)]
-fn AddTen(n: i32) -> i32 {
+fn add_ten(n: i32) -> i32 {
// integers implement `View` so they can be passed by value
n + 10
}
@@ -243,7 +242,7 @@ fn main() {
kobold::start(view! {
"Meaning of life is "
- { 32 }
+ { 32 }!add_ten>
});
}
@@ -251,7 +250,7 @@ fn main() {
## More Examples
-To run **Kobold** you'll need to install [`trunk`](https://trunkrs.dev/) (check the [full instructions](https://trunkrs.dev/#install) if you have problems):
+To run **Kobold** you'll need to install [`trunk`](https://trunkrs.dev/):
```sh
cargo install --locked trunk
```
diff --git a/crates/kobold/Cargo.toml b/crates/kobold/Cargo.toml
index 9a30e901..2dee2952 100644
--- a/crates/kobold/Cargo.toml
+++ b/crates/kobold/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "kobold"
-version = "0.9.1"
+version = "0.10.0"
authors = ["Maciej Hirsz "]
edition = "2021"
license = "MPL-2.0"
@@ -19,7 +19,7 @@ stateful = []
wasm-bindgen = "0.2.84"
wasm-bindgen-futures = "0.4.34"
itoa = "1.0.6"
-kobold_macros = { version = "0.9.0", path = "../kobold_macros" }
+kobold_macros = { version = "0.10.0", path = "../kobold_macros" }
console_error_panic_hook = "0.1.7"
rlsf = { version = "0.2.1", optional = true }
serde = { version = "1", optional = true }
diff --git a/crates/kobold/js/util.js b/crates/kobold/js/util.js
index cd701a72..f705f994 100644
--- a/crates/kobold/js/util.js
+++ b/crates/kobold/js/util.js
@@ -44,11 +44,9 @@ export function removeClass(n,v) { n.classList.remove(v); }
export function replaceClass(n,o,v) { n.classList.replace(o,v); }
export function toggleClass(n,c,v) { n.classList.toggle(c,v); }
-export function makeEventHandler(c,f) { return (e) => koboldCallback(e,c,f); }
-export function checkEventHandler() { if (typeof koboldCallback !== "function") console.error(
-`Missing \`koboldCallback\` in global scope.
-Add the following to your Trunk.toml:
-
-[build]
-pattern_script = ""
+export function makeEventHandler(c,f) { return (e) => wasmBindings.koboldCallback(e,c,f); }
+export function checkEventHandler() { if (typeof wasmBindings !== "object") console.error(
+`Missing \`wasmBindings\` in global scope.
+As of Kobold v0.10 and Trunk v0.17.16 you no longer need to export bindings manually, \
+please remove the custom \`pattern_script\' from your \`Trunk.toml\` file.
`) }
diff --git a/crates/kobold/src/branching.rs b/crates/kobold/src/branching.rs
index d5d96f7e..ce2c6235 100644
--- a/crates/kobold/src/branching.rs
+++ b/crates/kobold/src/branching.rs
@@ -9,7 +9,7 @@
//! ```compile_fail
//! # use kobold::prelude::*;
//! #[component]
-//! fn Conditional(illuminatus: bool) -> impl View {
+//! fn conditional(illuminatus: bool) -> impl View {
//! if illuminatus {
//! view! {
"It was the year when they finally immanentized the Eschaton."
"It was the year when they finally immanentized the Eschaton."
}
//! } else {
//! view! {
"It was love at first sight."
}
//! }
//! }
+//! # fn main() {}
//! ```
//!
//! This flag is not enabled by default, yet, as there might be situations [`auto_branch`](crate::component#componentauto_branch)
@@ -59,7 +60,7 @@
//! use kobold::branching::Branch2;
//!
//! #[component]
-//! fn Conditional(illuminatus: bool) -> impl View {
+//! fn conditional(illuminatus: bool) -> impl View {
//! if illuminatus {
//! Branch2::A(view! {
//!
"It was the year when they finally immanentized the Eschaton."
@@ -70,16 +71,17 @@
//! })
//! }
//! }
+//! # fn main() {}
//! ```
//!
//! This is in fact all that the [`auto_branch`](crate::component#componentauto_branch) flag does for you automatically.
//!
-//! For simple optional renders you can always use the standard library [`Option`](Option):
+//! For simple optional renders you can always use the standard library [`Option`]:
//!
//! ```
//! # use kobold::prelude::*;
//! #[component]
-//! fn Conditional(illuminatus: bool) -> impl View {
+//! fn conditional(illuminatus: bool) -> impl View {
//! if illuminatus {
//! Some(view! {
//!
"It was the year when they finally immanentized the Eschaton."
@@ -88,6 +90,7 @@
//! None
//! }
//! }
+//! # fn main() {}
//! ```
use std::mem::MaybeUninit;
diff --git a/crates/kobold/src/diff.rs b/crates/kobold/src/diff.rs
index 08621d26..9ee09c62 100644
--- a/crates/kobold/src/diff.rs
+++ b/crates/kobold/src/diff.rs
@@ -35,7 +35,7 @@ pub use vstring::VString;
/// }
///
/// #[component]
-/// fn UserRow(user: &User) -> impl View + '_ {
+/// fn user_row(user: &User) -> impl View + '_ {
/// fence(user.id, || view! {
/// // This row is only re-rendered if `user.id` has changed
///
@@ -48,6 +48,7 @@ pub use vstring::VString;
///
/// })
/// }
+/// # fn main() {}
/// ```
pub const fn fence(guard: D, render: F) -> Fence
where
@@ -61,7 +62,7 @@ where
}
}
-/// Smart [`View`](View) that guards against unnecessary renders, see [`fence`](fence).
+/// Smart [`View`] that guards against unnecessary renders, see [`fence`].
pub struct Fence {
guard: D,
inner: F,
@@ -165,7 +166,7 @@ macro_rules! impl_diff {
impl_diff_str!(&str, &String);
impl_diff!(bool, u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, f32, f64);
-/// Smart [`View`](View) that only updates its content when the reference to T has changed.
+/// Smart [`View`] that only updates its content when the reference to T has changed.
/// See [`ref`](crate::keywords::ref).
#[repr(transparent)]
pub struct Ref(T);
@@ -203,7 +204,7 @@ impl Diff for &Ref {
}
}
-/// Smart [`View`](View) that never performs diffing and instead always triggers
+/// Smart [`View`] that never performs diffing and instead always triggers
/// updates.
///
/// See [`use`](crate::keywords::use)
@@ -211,7 +212,7 @@ impl Diff for &Ref {
#[repr(transparent)]
pub struct Eager(pub(crate) T);
-/// Smart [`View`](View) that never performs diffing and instead never triggers
+/// Smart [`View`] that never performs diffing and instead never triggers
/// updates.
///
/// See [`static`](crate::keywords::static)
diff --git a/crates/kobold/src/dom.rs b/crates/kobold/src/dom.rs
index 67eba1a4..f6f9ba08 100644
--- a/crates/kobold/src/dom.rs
+++ b/crates/kobold/src/dom.rs
@@ -27,7 +27,7 @@ pub trait Mountable: 'static {
fn replace_with(&self, new: &JsValue);
}
-/// A light-weight [`Deref`](Deref)-like trait that
+/// A light-weight [`Deref`]-like trait that
/// auto-implements `Mountable` by proxying it to another type.
pub trait Anchor {
type Js: JsCast;
diff --git a/crates/kobold/src/internal.rs b/crates/kobold/src/internal.rs
index 87b1d5b2..5aed365c 100644
--- a/crates/kobold/src/internal.rs
+++ b/crates/kobold/src/internal.rs
@@ -15,14 +15,14 @@ use crate::View;
/// Uninitialized stable pointer to `T`.
///
-/// Used for the initialize-in-place strategy employed by the [`View::build`](View::build) method.
+/// Used for the initialize-in-place strategy employed by the [`View::build`] method.
#[must_use]
#[repr(transparent)]
pub struct In<'a, T>(&'a mut MaybeUninit);
/// Initialized stable pointer to `T`.
///
-/// Used for the initialize-in-place strategy employed by the [`View::build`](View::build) method.
+/// Used for the initialize-in-place strategy employed by the [`View::build`] method.
#[repr(transparent)]
pub struct Out<'a, T>(&'a mut T);
@@ -174,7 +174,7 @@ macro_rules! init {
};
}
-/// Wrapper that turns `extern` precompiled JavaScript functions into [`View`](View)s.
+/// Wrapper that turns `extern` precompiled JavaScript functions into [`View`]s.
#[repr(transparent)]
pub struct Precompiled(pub F);
diff --git a/crates/kobold/src/keywords.rs b/crates/kobold/src/keywords.rs
index 805f6b93..7217e6c7 100644
--- a/crates/kobold/src/keywords.rs
+++ b/crates/kobold/src/keywords.rs
@@ -8,7 +8,7 @@ use crate::diff::{Eager, Ref, Static};
use crate::list::List;
use crate::View;
-/// `{ for ... }`: turn an [`IntoIterator`](IntoIterator) type into a [`View`](View).
+/// `{ for ... }`: turn an [`IntoIterator`] type into a [`View`].
///
/// ```
/// # use kobold::prelude::*;
@@ -42,7 +42,7 @@ where
/// }
///
/// #[component]
-/// fn UserRow(user: &User) -> impl View + '_ {
+/// fn user_row(user: &User) -> impl View + '_ {
/// view! {
///
/// // If `name` and `email` are always sent to the UI as
@@ -53,6 +53,7 @@ where
///
/// }
/// }
+/// # fn main() {}
/// ```
pub const fn r#ref(value: &str) -> &Ref {
unsafe { &*(value as *const _ as *const Ref) }
diff --git a/crates/kobold/src/lib.rs b/crates/kobold/src/lib.rs
index b95f6952..f2b6f51f 100644
--- a/crates/kobold/src/lib.rs
+++ b/crates/kobold/src/lib.rs
@@ -27,8 +27,8 @@
//! string or an integer only updates the exact [`Text` node](https://developer.mozilla.org/en-US/docs/Web/API/Text)
//! that string or integer was rendered to.
//!
-//! _If the [`view!`](view) macro invocation contains DOM elements with no expressions, the constructed [`View`](View)
-//! type will be zero-sized, and its [`View::update`](View::update) method will be empty, making updates of static
+//! _If the [`view!`](view) macro invocation contains DOM elements with no expressions, the constructed [`View`]
+//! type will be zero-sized, and its [`View::update`] method will be empty, making updates of static
//! HTML literally zero-cost._
//!
//! ### Hello World!
@@ -39,7 +39,7 @@
//! use kobold::prelude::*;
//!
//! #[component]
-//! fn Hello(name: &str) -> impl View + '_ {
+//! fn hello(name: &str) -> impl View + '_ {
//! view! {
//!
"Hello "{ name }"!"
//! }
@@ -47,12 +47,12 @@
//!
//! fn main() {
//! kobold::start(view! {
-//!
+//!
//! });
//! }
//! ```
//!
-//! The component function must return a type that implements the [`View`](View) trait. Since the [`view!`](view) macro
+//! The component function must return a type that implements the [`View`] trait. Since the [`view!`](view) macro
//! produces transient locally defined types the best approach here is to always use the opaque `impl View` return type.
//!
//! Everything here is statically typed and the macro doesn't delete any information when manipulating the
@@ -62,8 +62,8 @@
//! error[E0560]: struct `Hello` has no field named `nam`
//! --> examples/hello_world/src/main.rs:12:16
//! |
-//! 12 |
-//! | ^^^ help: a field with a similar name exists: `name`
+//! 12 |
+//! | ^^^ help: there is a method with a similar name: `name`
//! ```
//!
//! You can even use [rust-analyzer](https://rust-analyzer.github.io/) to refactor component or field names,
@@ -78,7 +78,7 @@
//! use kobold::prelude::*;
//!
//! #[component]
-//! fn Counter(init: u32) -> impl View {
+//! fn counter(init: u32) -> impl View {
//! stateful(init, |count| {
//! bind! { count:
//! // Create an event handler with access to `&mut u32`
@@ -98,7 +98,7 @@
//!
//! fn main() {
//! kobold::start(view! {
-//!
+//!
//! });
//! }
//! ```
@@ -123,20 +123,21 @@
//! # use kobold::prelude::*;
//! // `code` will default to `200` if omitted
//! #[component(code?: 200)]
-//! fn Status(code: u32) -> impl View {
+//! fn status(code: u32) -> impl View {
//! view! {
//!
"Status code was "{ code }
//! }
//! }
//!
+//! # fn main() {
//! # let _ =
//! view! {
//! // Status code was 200
-//!
+//!
//! // Status code was 404
-//!
+//!
//! }
-//! # ;
+//! # ; }
//! ```
//!
//! For more details visit the [`#[component]` macro documentation](component#optional-parameters-componentparam).
@@ -153,13 +154,14 @@
//! ```
//! # use kobold::prelude::*;
//! #[component(auto_branch)]
-//! fn Conditional(illuminatus: bool) -> impl View {
+//! fn conditional(illuminatus: bool) -> impl View {
//! if illuminatus {
//! view! {
"It was the year when they finally immanentized the Eschaton." }
//! } else {
//! view! {
"It was love at first sight." }
//! }
//! }
+//! # fn main() {}
//! ```
//!
//! For more details visit the [`branching` module documentation](branching).
@@ -172,7 +174,7 @@
//! use kobold::prelude::*;
//!
//! #[component]
-//! fn IterateNumbers(count: u32) -> impl View {
+//! fn iterate_numbers(count: u32) -> impl View {
//! view! {
//!
//! {
@@ -180,6 +182,7 @@
//! }
//! }
//! }
+//! # fn main() {}
//! ```
//!
//! On updates the iterator is consumed once and all items are diffed with the previous version.
@@ -190,14 +193,14 @@
//!
//! ### Borrowed Values
//!
-//! [`View`](View) types are truly transient and only need to live for the duration of the initial render,
+//! [`View`] types are truly transient and only need to live for the duration of the initial render,
//! or for the duration of the subsequent update. This means that you can easily and cheaply render borrowed
//! state without unnecessary clones:
//!
//! ```
//! # use kobold::prelude::*;
//! #[component]
-//! fn Users<'a>(names: &'a [&'a str]) -> impl View + 'a {
+//! fn users<'a>(names: &'a [&'a str]) -> impl View + 'a {
//! view! {
//!
/// }
/// }
+/// # fn main() {}
/// ```
///
/// ## Flags
@@ -296,7 +301,7 @@
///
/// Allows for parameters to have default values. Available syntax:
///
-/// * `#[component(foo?)]`: mark the parameter `foo` as optional, use [`Default`](Default) trait implementation if absent.
+/// * `#[component(foo?)]`: mark the parameter `foo` as optional, use [`Default`] trait implementation if absent.
/// * `#[component(foo?: )]`: mark the parameter `foo` as optional, default to ``.
///
/// #### Examples
@@ -308,7 +313,7 @@
/// // Make `age` an optional parameter, use the `Default` value
/// age?,
/// )]
-/// fn Greeter<'a>(name: &'a str, age: Option) -> impl View + 'a {
+/// fn greeter<'a>(name: &'a str, age: Option) -> impl View + 'a {
/// let age = age.map(|age| view!(", you are "{ age }" years old"));
///
/// view! {
@@ -316,44 +321,44 @@
/// }
/// }
///
-/// # let _ =
+/// # fn main() { let _ =
/// view! {
/// // Hello Kobold
-///
+///
/// // Hello Alice
-///
+///
/// // Hello Bob, you are 42 years old
-///
+///
/// }
-/// # ;
+/// # ; }
/// ```
///
/// Optional parameters of any type `T` can be set using any type that implements
/// [`Maybe`](crate::maybe::Maybe).
///
-/// This allows you to set optional parameters using an [`Option`](Option):
+/// This allows you to set optional parameters using an [`Option`]:
/// ```
/// # use kobold::prelude::*;
/// #[component(code?: 200)]
-/// fn StatusCode(code: u32) -> impl View {
+/// fn status_code(code: u32) -> impl View {
/// view! {
///
"Status code was "{ code }
/// }
/// }
///
-/// # let _ =
+/// # fn main() { let _ =
/// view! {
/// // Status code was 200
-///
+///
/// // Status code was 404
-///
+///
///
/// // Status code was 200
-///
+///
/// // Status code was 500
-///
+///
/// }
-/// # ;
+/// # ; }
/// ```
///
/// All values are lazy-evaluated:
@@ -362,16 +367,17 @@
/// # use kobold::prelude::*;
/// // The owned `String` will only be created if the `name` is not set.
/// #[component(name?: "Kobold".to_string())]
-/// fn Greeter(name: String) -> impl View {
+/// fn greeter(name: String) -> impl View {
/// view! {
///
"Hello "{ name }
/// }
/// }
+/// # fn main() {}
/// ```
///
/// #### 💡 Note:
///
-/// You can only mark types that implement the [`Default`](Default) trait as optional, even if you provide
+/// You can only mark types that implement the [`Default`] trait as optional, even if you provide
/// a concrete value using `param?: value`. This requirement might be relaxed in the future when trait
/// specialization is stabilized.
///
@@ -390,7 +396,7 @@
/// * `#[component(children: my_name)]`: children will be captured by the `my_name` argument on the function.
pub use kobold_macros::component;
-/// Macro for creating transient [`View`](View) types. See the [main documentation](crate) for details.
+/// Macro for creating transient [`View`] types. See the [main documentation](crate) for details.
pub use kobold_macros::view;
use wasm_bindgen::JsCast;
@@ -533,7 +539,7 @@ where
}
}
-/// Start the Kobold app by mounting given [`View`](View) in the document `body`.
+/// Start the Kobold app by mounting given [`View`] in the document `body`.
pub fn start(view: impl View) {
init_panic_hook();
@@ -556,7 +562,7 @@ fn init_panic_hook() {
use std::cell::Cell;
thread_local! {
- static INIT: Cell = Cell::new(false);
+ static INIT: Cell = const { Cell::new(false) };
}
if !INIT.with(|init| init.get()) {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
diff --git a/crates/kobold/src/maybe.rs b/crates/kobold/src/maybe.rs
index cf0770db..7cf5d690 100644
--- a/crates/kobold/src/maybe.rs
+++ b/crates/kobold/src/maybe.rs
@@ -2,12 +2,12 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-//! The [`Maybe`](Maybe) trait and its implementations
+//! The [`Maybe`] trait and its implementations
/// Undefined component parameter. If you've encountered this type it usually means
/// you've failed to set a required component parameter.
///
-/// This is a zero-sized type that implements [`Maybe`](Maybe) for all `T: Default`.
+/// This is a zero-sized type that implements [`Maybe`](Maybe) for all `T`.
pub struct Undefined;
/// Helper trait for handling optional parameters in components.
diff --git a/crates/kobold/src/stateful.rs b/crates/kobold/src/stateful.rs
index 80232f4b..457a41e0 100644
--- a/crates/kobold/src/stateful.rs
+++ b/crates/kobold/src/stateful.rs
@@ -8,7 +8,7 @@
//! is no way to update them short of the parent view re-rendering them.
//!
//! However a fully functional app like that wouldn't be very useful, as all it
-//! could ever do is render itself once. To get around this the [`stateful`](stateful) function can
+//! could ever do is render itself once. To get around this the [`stateful`] function can
//! be used to create views that have ownership over some arbitrary mutable state.
//!
use std::cell::UnsafeCell;
@@ -50,8 +50,8 @@ pub struct StatefulProduct {
inner: Rc>,
}
-/// Create a stateful [`View`](crate::View) over some mutable state. The state
-/// needs to be created using the [`IntoState`](IntoState) trait.
+/// Create a stateful [`View`] over some mutable state. The state
+/// needs to be created using the [`IntoState`] trait.
///
/// ```
/// # use::kobold::prelude::*;
diff --git a/crates/kobold/src/stateful/hook.rs b/crates/kobold/src/stateful/hook.rs
index 66cc80f9..18ddd4ef 100644
--- a/crates/kobold/src/stateful/hook.rs
+++ b/crates/kobold/src/stateful/hook.rs
@@ -283,6 +283,6 @@ mod test {
};
// Make sure we can copy the mock twice
- drop([mock, mock]);
+ let _ = [mock, mock];
}
}
diff --git a/crates/kobold/src/value.rs b/crates/kobold/src/value.rs
index 87f7b105..0905f81b 100644
--- a/crates/kobold/src/value.rs
+++ b/crates/kobold/src/value.rs
@@ -81,7 +81,7 @@ impl View for String {
p.put(TextProduct { memo: self, node })
}
- fn update(self, mut p: &mut Self::Product) {
+ fn update(self, p: &mut Self::Product) {
if p.memo != self {
p.memo = self;
p.memo.set_prop(TextContent, &p.node);
diff --git a/crates/kobold_macros/Cargo.toml b/crates/kobold_macros/Cargo.toml
index 72a007fc..7629f465 100644
--- a/crates/kobold_macros/Cargo.toml
+++ b/crates/kobold_macros/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "kobold_macros"
-version = "0.9.0"
+version = "0.10.0"
authors = ["Maciej Hirsz "]
edition = "2021"
license = "MPL-2.0"
@@ -15,10 +15,10 @@ documentation = "https://docs.rs/kobold"
arrayvec = "0.7.2"
beef = "0.5.2"
fnv = "1.0.7"
-once_cell = "1.17.1"
+once_cell = "1.19.0"
[dev-dependencies]
-proc-macro2 = "1.0.51"
+proc-macro2 = "1.0.79"
[lib]
proc-macro = true
diff --git a/crates/kobold_macros/src/branching/parse.rs b/crates/kobold_macros/src/branching/parse.rs
index c66c6e49..c9ecd200 100644
--- a/crates/kobold_macros/src/branching/parse.rs
+++ b/crates/kobold_macros/src/branching/parse.rs
@@ -158,7 +158,7 @@ fn parse_code(stream: &mut ParseStream, scope: Branches) -> Result, Pa
match maybe_html.into_inner() {
Ok(html) => {
- let branches = scope.map(Clone::clone);
+ let branches = scope.cloned();
let span = html[0].span();
code.push(Code::Scoped(Scoped::new(
diff --git a/crates/kobold_macros/src/dom.rs b/crates/kobold_macros/src/dom.rs
index 98519161..49556f9b 100644
--- a/crates/kobold_macros/src/dom.rs
+++ b/crates/kobold_macros/src/dom.rs
@@ -21,9 +21,7 @@ pub fn parse(tokens: TokenStream) -> Result, ParseError> {
let mut nodes = Vec::new();
- while let Some(node) = Node::parse(&mut stream)? {
- nodes.push(node);
- }
+ while Node::parse(&mut stream, &mut nodes)? > 0 {}
if nodes.is_empty() {
return Err(ParseError::new("Empty view! invocation", Span::call_site()));
@@ -91,23 +89,23 @@ impl From for AttributeValue {
}
impl Node {
- fn parse(stream: &mut ShallowStream) -> Result