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

Implement ToView manually for types #541

Merged
merged 4 commits into from
Dec 11, 2022
Merged

Conversation

lukechu10
Copy link
Collaborator

@lukechu10 lukechu10 commented Dec 9, 2022

This lets us do some nice things such as:

let show = true;
view! { cx,
    (show.then(|| view! { cx, "Hello!" }))
}

Breaking Changes:

  • IntoView renamed to ToView (which is more idiomatic in Rust)
  • IntoView::create renamed to ToView::to_view
  • Not all types that implement Display now implement ToView. For those types that used to implement IntoView but do not now implement ToView, a simple fix would be to just add a to_string() at the call-site.

This also allows us to implement ToView for Option<T> and [T] where T: ToView among other types
@lukechu10 lukechu10 added BREAKING CHANGE Breaking changes introduced in this PR A-ergonomics Area: API ergonomics labels Dec 9, 2022
@codecov
Copy link

codecov bot commented Dec 9, 2022

Codecov Report

Base: 63.21% // Head: 63.24% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (5601e56) compared to base (e217544).
Patch coverage: 66.66% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #541      +/-   ##
==========================================
+ Coverage   63.21%   63.24%   +0.03%     
==========================================
  Files          54       54              
  Lines        8965     8944      -21     
==========================================
- Hits         5667     5657      -10     
+ Misses       3298     3287      -11     
Impacted Files Coverage Δ
packages/sycamore-core/src/generic_node.rs 75.00% <ø> (-0.45%) ⬇️
packages/sycamore-web/src/dom_node.rs 0.00% <ø> (ø)
website/src/content.rs 0.00% <0.00%> (ø)
website/src/header.rs 0.00% <0.00%> (ø)
packages/sycamore-core/src/view.rs 72.66% <72.91%> (-3.40%) ⬇️
packages/sycamore-macro/src/view/codegen.rs 95.58% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lukechu10 lukechu10 added the performance Performance related label Dec 11, 2022
@github-actions
Copy link

Benchmark Report

  • wasm-bindgen: the performance goal
  • baseline: performance of sycamore-baseline (typically latest master)
  • update: performance of sycamore (typically recent changes)
  • diff: measures the improvement of update over the baseline
@@                           Performance Diff                           @@

##                          | wasm-bindgen | baseline |  update |  diff ##
##########################################################################
+ 01_run1k                  |       103.85 |   125.37 |  117.93 |   -5.93%
+ 02_replace1k              |       108.77 |   144.71 |  130.36 |   -9.92%
+ 03_update10th1k_x16       |       222.21 |   273.56 |  244.82 |  -10.51%
+ 04_select1k               |        24.35 |    32.63 |   26.21 |  -19.66%
  05_swap1k                 |        62.24 |    68.70 |   68.35 |   -0.50%
  06_remove-one-1k          |       110.91 |   117.67 |  120.23 |   +2.18%
  07_create10k              |      1071.53 |  1292.23 | 1313.63 |   +1.66%
  08_create1k-after1k_x2    |       240.80 |   269.17 |  273.40 |   +1.57%
- 09_clear1k_x8             |        65.02 |    87.41 |   90.86 |   +3.95%
  21_ready-memory           |         1.86 |     1.85 |    1.85 |   -0.03%
  22_run-memory             |         2.84 |     5.54 |    5.55 |   +0.16%
  23_update5-memory         |         3.00 |     5.70 |    5.70 |   +0.08%
  25_run-clear-memory       |         1.92 |     4.35 |    4.36 |   +0.18%
  26_run-10k-memory         |        13.34 |    39.73 |   39.74 |   +0.02%
- 31_startup-ci             |      1832.45 |  1967.08 | 2032.26 |   +3.31%
  32_startup-bt             |         0.00 |     0.00 |    0.00 |     NaN%
+ 33_startup-mainthreadcost |        18.06 |    14.36 |    9.31 |  -35.17%
  34_startup-totalbytes     |       189.33 |   304.26 |  302.60 |   -0.55%

Workflow: 3666643752
Adding new commits will generate a new report

@lukechu10 lukechu10 merged commit 4861135 into sycamore-rs:master Dec 11, 2022
@lukechu10 lukechu10 deleted the to-view branch December 11, 2022 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ergonomics Area: API ergonomics BREAKING CHANGE Breaking changes introduced in this PR performance Performance related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant