slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.59k stars 604 forks source link

Implement `FromIterator` for `SharedString` #6232

Open Enyium opened 1 month ago

Enyium commented 1 month ago

I implemented a global-singleton callback in Rust that edits a SharedString by iterating over its characters, filtering them and collect()ing them back into a String, then using .into() to return a SharedString again.

Looking at the source code, this copies the data unnecessarily. If SharedString implemented FromIterator, I could directly collect() into a SharedString.

ogoffart commented 1 month ago

True, it could implement it just like String from std implements it.