MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus-components / selected_text

Function selected_text

primitives/src/selection.rs:82–97  ·  view source on GitHub ↗

Display text for selected values in selection order.

(
    values: impl IntoIterator<Item = &'a RcPartialEqValue>,
    options: &[OptionState],
)

Source from the content-addressed store, hash-verified

80
81/// Display text for selected values in selection order.
82pub(crate) fn selected_text<'a>(
83 values: impl IntoIterator<Item = &'a RcPartialEqValue>,
84 options: &[OptionState],
85) -> Option<String> {
86 let parts: Vec<String> = values
87 .into_iter()
88 .filter_map(|value| {
89 options
90 .iter()
91 .find(|option| &option.value == value)
92 .map(|option| option.text_value.clone())
93 })
94 .collect();
95
96 (!parts.is_empty()).then(|| parts.join(", "))
97}
98
99/// Insert or update a registered option.
100pub(crate) fn sync_option(mut options: Signal<Vec<OptionState>>, option_state: OptionState) {

Callers 1

selected_textMethod · 0.85

Calls 2

iterMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected