Why is get_mut_unchecked required?
Form::state_mut() (see below) calls RC::get_mut_unchecked which is unsafe and nightly only. Unfortunately, it is not documented why this is necessary (and why Rc::get_mut() cannot be used instead). Changing this would allow us to remove the feature requirement. As a result, it would be possible to compile yew_form on stable Rust.
https://github.com/jfbilodeau/yew_form/blob/afd25efe8bd367ffc5fb15e65aae1afce0af5e17/yew_form/src/form.rs#L24-L28
Done. Thanks!
@jfbilodeau Why is the feature requirement stilll there? https://github.com/jfbilodeau/yew_form/blob/5ce6bf65e400258ff0d3483df82d0cf17b0a45e5/yew_form/src/lib.rs#L1 Currently I am not able to compile this on stable rust.
Thanks for the heads up @L0g4n . My oversight. I remove the offending line and updated the crate. Please let me know if it compiles successfully for you.
@jfbilodeau Thanks. I apologize if I sounded a bit harsh, I really appreciate your work here.
@L0g4n: No offence taken. I appreciate the correction.
@jfbilodeau Sorry to bother again, but when I try to reproduce your form example I now get
panicked at 'called `Option::unwrap()` on a `None` value', ~\.cargo\registry\src\github.com-1ecc6299db9ec823\yew_form-0.1.7\src\form.rs:24:39 from your most recent commit.
This happens as soon as the oninput callback from the form is called, i.e. I type some sample text and then the panic happens.
Hey @L0g4n, I'm having a hard time reproducing the problem at my end. Any chance you could send me a bit more details? Platform? How are you running the app? Anything else? Thanks!
Sure, I hope this is a minimal reproducible example: https://gist.github.com/L0g4n/aa943183eff937cfb90865563a03fe2a Platform: x86_64-pc-windows-msvc Edit: I am running the app via yarn, with the rust webpack plugin.
@jfbilodeau Could you reproduce the unwrap error with the code submitted in the gist or do you need more information?
@L0g4n: Working on it. Any chance you could share with me your cargo.toml and lib.rs?
Sure.
[lib]
crate-type = ["cdylib", "rlib"]
[features]
default = ["wee_alloc"]
[dependencies]
yew = "0.17.3"
wasm-bindgen = "0.2.67"
wee_alloc = { version = "0.4.5", optional = true }
log = "0.4.11"
wasm-logger = "0.2.0"
console_error_panic_hook = "0.1.6"
anyhow = "1.0.32"
serde = { version = "1.0", features = ["derive"] }
# validator backend for `yew_form`
validator = { version = "0.10" }
validator_derive = "0.10"
yew_form = "0.1"
yew_form_derive = "0.1"
[dev-dependencies]
wasm-bindgen-test = "0.3"
lib.rs:
#![recursion_limit = "512"]
use wasm_bindgen::prelude::*;
mod api;
mod app;
mod models;
mod view;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
/// This is the entry point for the web app
#[wasm_bindgen]
pub fn run_app() {
wasm_logger::init(wasm_logger::Config::default());
// eases debugging by forwarding panic messages to the web console in debug mode
#[cfg(debug_assertions)]
console_error_panic_hook::set_once();
yew::start_app::<view::Home>();
}
Hey @L0g4n, sorry to bother you but I'm having trouble reproducing the crash with the code segments you provided. I hate to be a pain, but is there any chance you could privately share the full codebase to build and reproduce?
No problem, the frontend at this point in time is not that advanced. I have sent you an email with the source code. At this point I suspect that I am doing something unexpected with your library and this is why I get an unwrap traceback.
@jfbilodeau OK, so because I suspected an error from my side I just checked out this repo and built the example. Now: I get the same error here, as soon as I enter something in the form.

@L0g4n: Sorry, your issue slipped betweens the cracks. It should now be solved.