mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Use explicit Arc::clone to clarify when clones are cheap (#7784)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::{Demo, View};
|
||||
|
||||
use egui::{
|
||||
@@ -518,7 +520,7 @@ fn ui_stack_demo(ui: &mut Ui) {
|
||||
with various information.\n\nThis is how the stack looks like here:",
|
||||
);
|
||||
});
|
||||
let stack = ui.stack().clone();
|
||||
let stack = Arc::clone(ui.stack());
|
||||
egui::Frame::new()
|
||||
.inner_margin(ui.spacing().menu_margin)
|
||||
.stroke(ui.visuals().widgets.noninteractive.bg_stroke)
|
||||
|
||||
@@ -52,7 +52,7 @@ impl crate::View for Screenshot {
|
||||
.iter()
|
||||
.filter_map(|e| {
|
||||
if let egui::Event::Screenshot { image, .. } = e {
|
||||
Some(image.clone())
|
||||
Some(Arc::clone(image))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -62,7 +62,7 @@ impl crate::View for Screenshot {
|
||||
|
||||
if let Some(image) = image {
|
||||
self.image = Some((
|
||||
image.clone(),
|
||||
Arc::clone(&image),
|
||||
ui.ctx()
|
||||
.load_texture("screenshot_demo", image, Default::default()),
|
||||
));
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use egui::{
|
||||
Color32, Pos2, Rect, Sense, StrokeKind, Vec2,
|
||||
emath::{GuiRounding as _, TSTransform},
|
||||
@@ -229,8 +231,8 @@ impl crate::View for TessellationTest {
|
||||
TSTransform::from_translation(canvas.center().to_vec2())
|
||||
* TSTransform::from_scaling(magnification_pixel_size),
|
||||
);
|
||||
let mesh = std::sync::Arc::new(mesh);
|
||||
painter.add(epaint::Shape::mesh(mesh.clone()));
|
||||
let mesh = Arc::new(mesh);
|
||||
painter.add(epaint::Shape::mesh(Arc::clone(&mesh)));
|
||||
|
||||
if self.paint_edges {
|
||||
let stroke = epaint::Stroke::new(0.5, Color32::MAGENTA);
|
||||
|
||||
Reference in New Issue
Block a user