egui/egui_demo_lib
Emil Ernerfeldt b3e41e4e9c Use new type Estring to avoid cloning &'static str
`ui.label("static string")` is a very common use case,
and currently egui clones the string in these cases.

This PR introduces a new type:

``` rust
pub enum Estring {
    Static(&'static str),
    Owned(Arc<str>),
}
```

which is used everywhere text is needed, with
`impl Into<Estring>` in the API for e.g. `ui.label`.

This reduces the number of copies drastically and speeds up
the benchmark demo_with_tessellate__realistic by 17%.

This hurts the ergonomics of egui a bit, and this is a breaking change.

For instance, this used to work:

``` rust
fn my_label(ui: &mut egui::Ui, text: &str) {
    ui.label(text);
}
```

This must now either be changed to

``` rust
fn my_label(ui: &mut egui::Ui, text: &str) {
    ui.label(text.to_string());
}
```

(or the argument must be changed to either
`text: &'static str` or `text: String`)
2021-09-03 22:38:00 +02:00
..
benches Use new type Estring to avoid cloning &'static str 2021-09-03 22:38:00 +02:00
src Use new type Estring to avoid cloning &'static str 2021-09-03 22:38:00 +02:00
Cargo.toml Point crate repository & homepage urls to their subfolders 2021-09-03 21:12:44 +02:00
README.md Point crate repository & homepage urls to their subfolders 2021-09-03 21:12:44 +02:00

egui demo library

Latest version Documentation unsafe forbidden MIT Apache

This crate contains example code for egui.

It is in a separate crate for two reasons:

  • To ensure it only uses the public egui api.
  • To remove the amount of code in egui proper.