#Specifying attributes in string

1 messages · Page 1 of 1 (latest)

cursive parcel
#
use yew::prelude::*;

#[function_component(CheckMnemonic)]
pub fn check_mnemonic() -> Html {
    let phrase_state =
        use_state(|| vec!["India".to_owned(), "Norway".to_owned(), "Bhutan".to_owned()]);

    html! {
       <>

       {for phrase_state.iter().map(|cont|

        html!{
            <>
            <input type="text" class="form-control" readonly=true value={&cont[..]}/>
            </>
        }

    )}

       </>


    }
}

Gives error

error[E0597]: `phrase_state` does not live long enough
  --> src/components/accounts/multistep_account_creation/check_mnemonic.rs:63:14
   |
63 |         {for phrase_state.iter().map(|cont| {
   |              ^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
67 |                 <input type="text" class="form-control" readonly=true value={&cont[..]} onclick={add_tag.clone()}/>
   |                                                                              - argument requires that `phrase_state` is borrowed for `'static`
...
73 | }
   | - `phrase_state` dropped here while still borrowed
glacial ridge
#

you need to clone it.
the borrowed value is olz borrowed for the duration of the for loop, after that it becomes invalid

cursive parcel
#

where to clone. Using phase_state_clone doesn't work. let phrase_state_clone = phrase_state.clone();

glacial ridge
#

you need to clone the cont i thing
value={cont.clone()} or something like that