[pdm-devel] [PATCH proxmox-yew-widget-toolkit 1/1] data table: add get_property helper for displaying optional values
Stefan Hanreich
s.hanreich at proxmox.com
Wed Aug 20 12:46:11 CEST 2025
On 8/20/25 12:33 PM, Dominik Csapak wrote:
[snip]
> if you have an Option<&str> you can omit the .as_deref()
> ```
> Some("foo").unwrap_or("")
> ```
>
> works
>
I have an Option<String>, where it doesn't work afaict (without cloning).
[snip]
>>>> {{get_property_fn(item).map(VNode::from).unwrap_or_default()}},
>>>
>>> mhmm since we require the Display trait as boundary, wouldn't a
>>> to_string() be better here? The default for VNode is a VList, but an
>>> empty string produces a VText
>>
>> this allocates a string for every cell, whereas VList doesn't and both
>> are effectively the same (no HTML produced)
>
> yes it does, VNode::from for T which impl ToString (implicitly by
> Display) uses to_string too:
>
> https://docs.rs/yew/latest/src/yew/virtual_dom/vnode.rs.html#164-166
Ah sorry, I though you were talking about the Default case. Nevertheless
it would still make sense to use the Yew provided implementation then?
More information about the pdm-devel
mailing list