Skip to content

fix: add IntoPropValue impls for Cow<'static, str>#4051

Open
Madoshakalaka wants to merge 1 commit intomasterfrom
fix/cow-into-prop-value-3524
Open

fix: add IntoPropValue impls for Cow<'static, str>#4051
Madoshakalaka wants to merge 1 commit intomasterfrom
fix/cow-into-prop-value-3524

Conversation

@Madoshakalaka
Copy link
Member

@Madoshakalaka Madoshakalaka commented Mar 6, 2026

Description

The dynamic tag name issue (<@{value} /> requiring Cow<'static, str>) was already resolved in #3431, which switched to Into<AttrValue>.

The remaining gap was that component props typed as Cow<'static, str> could not accept common string types directly in the html! macro. This PR adds the missing IntoPropValue implementations:

  • &'static str to Cow<'static, str> (zero-cost via Cow::Borrowed)
  • String to Cow<'static, str> (via Cow::Owned)
  • Rc<str> to Cow<'static, str> (via Cow::Owned)

fixed now.

Fixes #3524

Checklist

  • I have reviewed my own code
  • I have added tests

Add missing IntoPropValue conversions targeting Cow<'static, str>
so that component props of that type can accept &'static str,
String, and Rc<str> directly in the html! macro.
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Benchmark - core

Yew Master

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.125 ns      │ 2.231 ns      │ 2.128 ns      │ 2.131 ns      │ 100     │ 1000000000

Pull Request

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.092 ns      │ 3.703 ns      │ 2.099 ns      │ 2.535 ns      │ 100     │ 1000000000

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Visit the preview URL for this PR (updated for commit 0561a55):

https://yew-rs-api--pr4051-fix-cow-into-prop-va-awrzc50h.web.app

(expires Fri, 13 Mar 2026 11:59:56 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@Madoshakalaka Madoshakalaka changed the title fix: add IntoPropValue impls for Cow<'static, str> (#3524) fix: add IntoPropValue impls for Cow<'static, str> Mar 6, 2026
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Size Comparison

Details
examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 100.272 100.272 0 0.000%
boids 168.099 168.099 0 0.000%
communication_child_to_parent 93.485 93.485 0 0.000%
communication_grandchild_with_grandparent 105.262 105.262 0 0.000%
communication_grandparent_to_grandchild 101.610 101.610 0 0.000%
communication_parent_to_child 90.899 90.899 0 0.000%
contexts 105.177 105.177 0 0.000%
counter 86.282 86.282 0 0.000%
counter_functional 88.276 88.276 0 0.000%
dyn_create_destroy_apps 90.322 90.322 0 0.000%
file_upload 99.377 99.377 0 0.000%
function_delayed_input 94.377 94.377 0 0.000%
function_memory_game 172.944 172.944 0 0.000%
function_router 406.599 406.599 0 0.000%
function_todomvc 164.163 164.163 0 0.000%
futures 235.191 235.191 0 0.000%
game_of_life 104.732 104.732 0 0.000%
immutable 255.891 255.891 0 0.000%
inner_html 80.803 80.803 0 0.000%
js_callback 109.401 109.401 0 0.000%
keyed_list 179.740 179.740 0 0.000%
mount_point 84.174 84.174 0 0.000%
nested_list 113.072 113.072 0 0.000%
node_refs 91.523 91.523 0 0.000%
password_strength 1729.185 1729.185 0 0.000%
portals 93.034 93.034 0 0.000%
router 377.158 377.158 0 0.000%
suspense 113.502 113.502 0 0.000%
timer 88.641 88.641 0 0.000%
timer_functional 98.881 98.881 0 0.000%
todomvc 142.114 142.114 0 0.000%
two_apps 86.176 86.176 0 0.000%
web_worker_fib 136.155 136.155 0 0.000%
web_worker_prime 187.383 187.383 0 0.000%
webgl 83.224 83.224 0 0.000%

✅ None of the examples has changed their size significantly.

@Madoshakalaka Madoshakalaka marked this pull request as ready for review March 6, 2026 12:09
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Benchmark - SSR

Yew Master

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 310.684 311.020 310.819 0.132
Hello World 10 466.676 480.954 472.929 5.409
Function Router 10 32245.863 33595.617 32861.627 416.651
Concurrent Task 10 1006.600 1007.864 1007.351 0.433
Many Providers 10 1085.728 1123.979 1102.260 13.995

Pull Request

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 310.582 312.502 311.132 0.543
Hello World 10 476.437 511.071 484.496 10.241
Function Router 10 34342.840 35310.333 34916.835 280.167
Concurrent Task 10 1005.740 1007.795 1006.875 0.677
Many Providers 10 1079.884 1105.710 1088.289 7.885

= help: the following other types implement trait `IntoPropValue<T>`:
`Option<&String>` implements `IntoPropValue<Option<VNode>>`
`Option<&implicit_clone::unsync::string::IString>` implements `IntoPropValue<Option<VNode>>`
`Option<&str>` implements `IntoPropValue<Option<Cow<'_, str>>>`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the diagnostic diffs are all cosmetic

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.

Align IString/AttrValue with Cow of element

1 participant