Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change label arg to impl Display #106

Merged
merged 1 commit into from
Sep 16, 2023
Merged

Conversation

jrmoulton
Copy link
Collaborator

I had picked Into<String> before because that seemed to me what made the most sense but using impl Display really makes more sense. One big benefit is that number types all impl Display but not Into<String> so with this numbers can just be used directly in labels which is what essentially what I had been going for with Into<String>. Should be a drop in replacement.

fn app_view() -> impl View {
    // create a counter reactive signal with initial value 0
    let (counter, set_counter) = create_signal(0);

    // create user interface with Floem view functions
    stack((
        label(move || counter.get()),           //  <----- can use an integer directly
        stack((
            text("Increment")
                .on_click(move |_| {
                    set_counter.update(|value| *value += 1);
                    true
                }),
            text("Decrement")
                .on_click(move |_| {
                    set_counter.update(|value| *value -= 1);
                    true
                }),
        )),
    ))
}

@codecov
Copy link

codecov bot commented Sep 16, 2023

Codecov Report

Merging #106 (96393e8) into main (49ca91c) will not change coverage.
The diff coverage is 0.00%.

@@          Coverage Diff          @@
##            main    #106   +/-   ##
=====================================
  Coverage   3.74%   3.74%           
=====================================
  Files         51      51           
  Lines       8564    8564           
=====================================
  Hits         321     321           
  Misses      8243    8243           
Files Changed Coverage Δ
src/views/label.rs 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dzhou121 dzhou121 merged commit afdad56 into lapce:main Sep 16, 2023
7 of 9 checks passed
@jrmoulton jrmoulton deleted the label-impl-display branch January 17, 2024 21:56
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