Editor cleanups / extensions, esp Rc<String> support#697
Conversation
dhardy
left a comment
There was a problem hiding this comment.
There is a weak incentive here to use Arc<String> instead of Rc<String> (since it supports Send). I'm not convinced it is sufficient motivation.
A stronger motivation might be to spawn a worker thread doing some work over cloned text contents so this might be revised later. (Note: &String is Send so it may still be possible to send text contents to a worker thread without a deep clone using scoped threads.)
| fn activate(&mut self, edit: &mut Editor, cx: &mut EventCx, _: &Data) -> IsUsed { | ||
| cx.push(Item::Edit(edit.clone_string())); | ||
| cx.push(Item::Edit(edit.clone_text())); | ||
| Used |
There was a problem hiding this comment.
The gallery can now clone by ref-count instead of copying String contents, passing Rc<String> as a message
| Button::label_msg("&Press me", Item::Button).map_any() | ||
| Button::label("&Press me").with(|cx, _| cx.push(Item::Button)).map_any() |
There was a problem hiding this comment.
One workaround was required: Button::label_msg requires the message type support Send (no longer the case due to usage of Rc). We can avoid this requirement by direct implementation of the closure.
…text: Rc<String>)
Some fixes / simplifications for recent PRs (see commits).
The editor types
CommonandPartare now pub. New pub fns:Common::direction, set_direction, update_direction, set_colorsPart::status, prepare_wrapimpl<S: ToString> From<S> for PartPart::textandEditor::text->&Rc<String>Part::clone_textandEditor::clone_text->Rc<String>Editor::set_text(&mut self, cx: _, text: Rc<String>