Compilation of example
I'm new to Rust and I'm trying to compile the example. There are a number of errors and I'm wondering what I'm doing wrong. Am I running the right version of Rust? (1.39)
error[E0658]: procedural macros cannot be expanded to expressions
--> src/main.rs:5:25
|
5 | const MY_STYLE: Style = define_style! {
| _________________________^
6 | | // Easily specify units on measurements, and do simple calculations with them.
7 | | text_size: 25 px + 1 vh,
8 | | padding: 10 px,
... |
18 | | }
19 | | };
| |_^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
error: expected `static`
--> src/main.rs:7:5
|
7 | text_size: 25 px + 1 vh,
| ^^^^^^^^^
error[E0433]: failed to resolve: use of undeclared type or module `topo`
--> src/main.rs:23:3
|
23 | #[topo::nested]
| ^^^^ use of undeclared type or module `topo`
error[E0433]: failed to resolve: use of undeclared type or module `topo`
--> src/main.rs:27:35
|
27 | let click_count: Key<usize> = state!(|| 0);
| ^^^^^^^^^^^^ use of undeclared type or module `topo`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: cannot find macro `my_app` in this scope
--> src/main.rs:60:49
|
60 | let runtime = moxie_native::Runtime::new(|| my_app!());
| ^^^^^^
error[E0599]: no method named `inner` found for type `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::app::App>` in the current scope
--> src/main.rs:38:5
|
38 | / mox! {
39 | | <app>
40 | | <window title="Moxie-Native Demo">
41 | | <view>
... |
54 | | </app>
55 | | }
| |_____^ method not found in `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::app::App>`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0277]: the trait bound `&str: moxie_native::dom::element::Attribute` is not satisfied
--> src/main.rs:38:5
|
38 | / mox! {
39 | | <app>
40 | | <window title="Moxie-Native Demo">
41 | | <view>
... |
54 | | </app>
55 | | }
| |_____^ the trait `moxie_native::dom::element::Attribute` is not implemented for `&str`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0277]: the trait bound `moxie_native::dom::elements::window::Window: moxie_native::dom::element::HasAttribute<&str>` is not satisfied
--> src/main.rs:38:5
|
38 | / mox! {
39 | | <app>
40 | | <window title="Moxie-Native Demo">
41 | | <view>
... |
54 | | </app>
55 | | }
| |_____^ the trait `moxie_native::dom::element::HasAttribute<&str>` is not implemented for `moxie_native::dom::elements::window::Window`
|
= help: the following implementations were found:
<moxie_native::dom::elements::window::Window as moxie_native::dom::element::HasAttribute<moxie_native::dom::attributes::AttrStyle>>
<moxie_native::dom::elements::window::Window as moxie_native::dom::element::HasAttribute<moxie_native::dom::attributes::AttrTitle>>
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0599]: no method named `inner` found for type `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::window::Window>` in the current scope
--> src/main.rs:38:5
|
38 | / mox! {
39 | | <app>
40 | | <window title="Moxie-Native Demo">
41 | | <view>
... |
54 | | </app>
55 | | }
| |_____^ method not found in `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::window::Window>`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0599]: no method named `inner` found for type `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::view::View>` in the current scope
--> src/main.rs:38:5
|
38 | / mox! {
39 | | <app>
40 | | <window title="Moxie-Native Demo">
41 | | <view>
... |
54 | | </app>
55 | | }
| |_____^ method not found in `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::view::View>`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> src/main.rs:38:5
|
38 | / mox! {
39 | | <app>
40 | | <window title="Moxie-Native Demo">
41 | | <view>
... |
54 | | </app>
55 | | }
| |_____^ expected struct `moxie_native::dom::attributes::AttrStyle`, found reference
|
= note: expected type `moxie_native::dom::attributes::AttrStyle`
found type `&'static str`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0599]: no method named `inner` found for type `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::button::Button>` in the current scope
--> src/main.rs:38:5
|
38 | / mox! {
39 | | <app>
40 | | <window title="Moxie-Native Demo">
41 | | <view>
... |
54 | | </app>
55 | | }
| |_____^ method not found in `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::button::Button>`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0599]: no method named `inner` found for type `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::span::Span>` in the current scope
--> src/main.rs:38:5
|
38 | / mox! {
39 | | <app>
40 | | <window title="Moxie-Native Demo">
41 | | <view>
... |
54 | | </app>
55 | | }
| |_____^ method not found in `moxie_native::moxie::elements::Builder<moxie_native::dom::elements::span::Span>`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 13 previous errors
It looks like you're using an old version of the define_style!() syntax, I recently changed it (see the examples directory for what the new syntax is like, it's more like lazy static where you define the static inside of the macro).
I also changed up the way you import the moxie-native code: you use use moxie_native::prelude::*; now to get everything you need. It also seems like your repo somehow has a non-patched version of the mox crate? I have it patched in the Cargo.toml to point to my local fork.
To avoid breaking changes while you're working on stuff, I'd suggest pinning to an exact git revision and only upgrading when comfortable, since I'm still in a phase of making frequent breaking changes as I get to the final design I want.
Ah, I forgot to update the readme.. I'll do that.
I think cargo patches might not work the way I expect, I'll change how I export the mox macro to fix that. In the mean time I think you can add this to your Cargo.toml as a workaround:
[patch.'https://github.com/anp/moxie.git']
mox = {
git = "https://github.com/tiffany352/moxie-native",
rev = "650fefed549418c58b4aac3c66c7c771f6f4426d" # whichever rev you're using for moxie-native itself
}
Thanks for the quick reply! Yeah I was using the README but I'll take a look at the examples you mentioned and the mox crate patch.
Sorry for the confusion! I just pushed an update to the readme, and I also just pushed a fix so that the patching is no longer needed.