Skip to content

Add str borrowing and fix hash calculation bug#7

Merged
cecton merged 3 commits into
yewstack:mainfrom
XX:add_str_borrowing
Jul 12, 2022
Merged

Add str borrowing and fix hash calculation bug#7
cecton merged 3 commits into
yewstack:mainfrom
XX:add_str_borrowing

Conversation

@XX
Copy link
Copy Markdown
Contributor

@XX XX commented Jul 9, 2022

@cecton Hashes of the IString::Static("foo") and IString::Rc(Rc::from("foo")) do not match. This is confusing when using an HashMap.

@cecton
Copy link
Copy Markdown
Contributor

cecton commented Jul 11, 2022

Good catch! Thanks a lot!

May I ask if you are working with Yew?

@cecton
Copy link
Copy Markdown
Contributor

cecton commented Jul 11, 2022

Looks like clippy might have spotted an interesting issue for once. It's possible that IString::Static("foo") != IString::Rc(Rc::from("foo")). Do you mind also fixing this and adding a test?

I don't know if it's okay for you but if possible I would really like to learn more about your use case for using IMap in a Yew web app (assuming that is what you are doing). Is it an OSS project I can read? Or could you drop a few lines or some code that explains how you use it?

@XX
Copy link
Copy Markdown
Contributor Author

XX commented Jul 12, 2022

@cecton I fixed it. )

I use Yew in my helper library yew-mdc-widgets of the Rust-and-Yew friendly builders for the Google MDC web components. For example:

let open_menu_button = Button::new()
    .label("Open Menu")
    .on_click(|_| Menu::open_existing("simple-menu"));

let menu = Menu::new().id("simple-menu").items(vec![
    ListItem::new().text("Menu Item 1"),
    ListItem::new().text("Menu Item 2"),
    ListItem::new().text("Menu Item 3"),
]);

html! {
    <div class = { Menu::ANCHOR_CLASS }>
        { open_menu_button }
        { menu }
    </div>
}

Live demo.
Direct link to using IndexMap in the code.

Additionaly, I will be using Yew and yew-mdc-widgets to develop applications for the Local-first web application platform Laplace.

@cecton
Copy link
Copy Markdown
Contributor

cecton commented Jul 12, 2022

It looks super interesting! Thanks! That might give me some inspiration for https://yewprint.rm.rs/

@cecton cecton merged commit 0c9a92f into yewstack:main Jul 12, 2022
@cecton
Copy link
Copy Markdown
Contributor

cecton commented Jul 12, 2022

Released in v0.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants