1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 14:49:06 -04:00

Remove impl Into<f32> arguments (#8194)

* Closes https://github.com/emilk/egui/issues/8179
This commit is contained in:
Emil Ernerfeldt
2026-05-25 10:59:03 +02:00
committed by GitHub
parent 67322e3ebf
commit 46c20810ba
9 changed files with 18 additions and 26 deletions

View File

@@ -418,7 +418,7 @@ mod tests {
if name == "Bézier Curve" { if name == "Bézier Curve" {
// The Bézier Curve demo needs a threshold of 2.1 to pass on linux: // The Bézier Curve demo needs a threshold of 2.1 to pass on linux:
options = options.threshold(OsThreshold::new(0.0).linux(2.1)); options = options.threshold(OsThreshold::new(0.0_f32).linux(2.1));
} }
results.add(harness.try_snapshot_options(format!("demos/{name}"), &options)); results.add(harness.try_snapshot_options(format!("demos/{name}"), &options));

View File

@@ -16,7 +16,7 @@ impl Default for DragAndDropDemo {
vec!["Item H", "Item I", "Item J", "Item K"], vec!["Item H", "Item I", "Item J", "Item K"],
] ]
.into_iter() .into_iter()
.map(|v| v.into_iter().map(ToString::to_string).collect()) .map(|v| v.into_iter().map(str::to_owned).collect())
.collect(), .collect(),
} }
} }

View File

@@ -45,7 +45,7 @@ impl crate::View for SceneDemo {
}); });
ui.separator(); ui.separator();
ui.label(format!("Scene rect: {:#?}", &mut self.scene_rect)); ui.label(format!("Scene rect: {:#?}", self.scene_rect));
ui.separator(); ui.separator();

View File

@@ -59,7 +59,7 @@ impl GlutinWindowContext {
) )
.expect("failed to create gl_config"); .expect("failed to create gl_config");
let gl_display = gl_config.display(); let gl_display = gl_config.display();
log::debug!("found gl_config: {:?}", &gl_config); log::debug!("found gl_config: {gl_config:?}");
let raw_window_handle = window.as_ref().map(|w| { let raw_window_handle = window.as_ref().map(|w| {
w.window_handle() w.window_handle()
@@ -77,9 +77,7 @@ impl GlutinWindowContext {
gl_display gl_display
.create_context(&gl_config, &context_attributes) .create_context(&gl_config, &context_attributes)
.unwrap_or_else(|_| { .unwrap_or_else(|_| {
log::debug!("failed to create gl_context with attributes: {:?}. retrying with fallback context attributes: {:?}", log::debug!("failed to create gl_context with attributes: {context_attributes:?}. retrying with fallback context attributes: {fallback_context_attributes:?}");
&context_attributes,
&fallback_context_attributes);
gl_config gl_config
.display() .display()
.create_context(&gl_config, &fallback_context_attributes) .create_context(&gl_config, &fallback_context_attributes)
@@ -106,10 +104,7 @@ impl GlutinWindowContext {
width, width,
height, height,
); );
log::debug!( log::debug!("creating surface with attributes: {surface_attributes:?}");
"creating surface with attributes: {:?}",
&surface_attributes
);
let gl_surface = unsafe { let gl_surface = unsafe {
gl_display gl_display
.create_window_surface(&gl_config, &surface_attributes) .create_window_surface(&gl_config, &surface_attributes)

View File

@@ -77,7 +77,7 @@ fn load_config() -> Config {
match std::fs::read_to_string(&config_path) { match std::fs::read_to_string(&config_path) {
Ok(config_str) => match toml::from_str(&config_str) { Ok(config_str) => match toml::from_str(&config_str) {
Ok(config) => config, Ok(config) => config,
Err(e) => panic!("Failed to parse {}: {e}", &config_path.display()), Err(e) => panic!("Failed to parse {}: {e}", config_path.display()),
}, },
Err(err) => { Err(err) => {
panic!("Failed to read {}: {}", config_path.display(), err); panic!("Failed to read {}: {}", config_path.display(), err);

View File

@@ -279,11 +279,7 @@ impl<'a, State> Harness<'a, State> {
/// Calculate the rect that includes all popups and tooltips. /// Calculate the rect that includes all popups and tooltips.
fn compute_total_rect_with_popups(&self) -> Option<Rect> { fn compute_total_rect_with_popups(&self) -> Option<Rect> {
// Start with the standard response rect // Start with the standard response rect
let mut used = if let Some(response) = self.response.as_ref() { let mut used = self.response.as_ref()?.rect;
response.rect
} else {
return None;
};
// Add all visible areas from other orders (popups, tooltips, etc.) // Add all visible areas from other orders (popups, tooltips, etc.)
self.ctx.memory(|mem| { self.ctx.memory(|mem| {

View File

@@ -173,8 +173,9 @@ impl SnapshotOptions {
/// The default is `0.6` (which is enough for most egui tests to pass across different /// The default is `0.6` (which is enough for most egui tests to pass across different
/// wgpu backends). /// wgpu backends).
#[inline] #[inline]
pub fn threshold(mut self, threshold: impl Into<f32>) -> Self { pub fn threshold(mut self, threshold: impl Into<OsThreshold<f32>>) -> Self {
self.threshold = threshold.into(); let threshold = threshold.into().threshold();
self.threshold = threshold;
self self
} }

View File

@@ -22,9 +22,9 @@ impl Stroke {
}; };
#[inline] #[inline]
pub fn new(width: impl Into<f32>, color: impl Into<Color32>) -> Self { pub fn new(width: f32, color: impl Into<Color32>) -> Self {
Self { Self {
width: width.into(), width,
color: color.into(), color: color.into(),
} }
} }
@@ -136,9 +136,9 @@ impl PathStroke {
}; };
#[inline] #[inline]
pub fn new(width: impl Into<f32>, color: impl Into<Color32>) -> Self { pub fn new(width: f32, color: impl Into<Color32>) -> Self {
Self { Self {
width: width.into(), width,
color: ColorMode::Solid(color.into()), color: ColorMode::Solid(color.into()),
kind: StrokeKind::Middle, kind: StrokeKind::Middle,
} }
@@ -149,11 +149,11 @@ impl PathStroke {
/// The bounding box passed to the callback will have a margin of [`TessellationOptions::feathering_size_in_pixels`](`crate::tessellator::TessellationOptions::feathering_size_in_pixels`) /// The bounding box passed to the callback will have a margin of [`TessellationOptions::feathering_size_in_pixels`](`crate::tessellator::TessellationOptions::feathering_size_in_pixels`)
#[inline] #[inline]
pub fn new_uv( pub fn new_uv(
width: impl Into<f32>, width: f32,
callback: impl Fn(Rect, Pos2) -> Color32 + Send + Sync + 'static, callback: impl Fn(Rect, Pos2) -> Color32 + Send + Sync + 'static,
) -> Self { ) -> Self {
Self { Self {
width: width.into(), width,
color: ColorMode::UV(Arc::new(callback)), color: ColorMode::UV(Arc::new(callback)),
kind: StrokeKind::Middle, kind: StrokeKind::Middle,
} }

View File

@@ -334,7 +334,7 @@ fn drag_and_drop_test(ui: &mut egui::Ui) {
assert!(col < COLS, "The coll should be less than: {COLS}"); assert!(col < COLS, "The coll should be less than: {COLS}");
let value: String = value.into(); let value: String = value.into();
let id = Id::new(format!("%{}% {}", self.counter, &value)); let id = Id::new(format!("%{}% {}", self.counter, value));
self.data.insert(id, value); self.data.insert(id, value);
let viewport_data = self.containers_data.entry(container).or_insert_with(|| { let viewport_data = self.containers_data.entry(container).or_insert_with(|| {
let mut res = Vec::new(); let mut res = Vec::new();