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" {
// 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));

View File

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

View File

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

View File

@@ -59,7 +59,7 @@ impl GlutinWindowContext {
)
.expect("failed to create gl_config");
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| {
w.window_handle()
@@ -77,9 +77,7 @@ impl GlutinWindowContext {
gl_display
.create_context(&gl_config, &context_attributes)
.unwrap_or_else(|_| {
log::debug!("failed to create gl_context with attributes: {:?}. retrying with fallback context attributes: {:?}",
&context_attributes,
&fallback_context_attributes);
log::debug!("failed to create gl_context with attributes: {context_attributes:?}. retrying with fallback context attributes: {fallback_context_attributes:?}");
gl_config
.display()
.create_context(&gl_config, &fallback_context_attributes)
@@ -106,10 +104,7 @@ impl GlutinWindowContext {
width,
height,
);
log::debug!(
"creating surface with attributes: {:?}",
&surface_attributes
);
log::debug!("creating surface with attributes: {surface_attributes:?}");
let gl_surface = unsafe {
gl_display
.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) {
Ok(config_str) => match toml::from_str(&config_str) {
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) => {
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.
fn compute_total_rect_with_popups(&self) -> Option<Rect> {
// Start with the standard response rect
let mut used = if let Some(response) = self.response.as_ref() {
response.rect
} else {
return None;
};
let mut used = self.response.as_ref()?.rect;
// Add all visible areas from other orders (popups, tooltips, etc.)
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
/// wgpu backends).
#[inline]
pub fn threshold(mut self, threshold: impl Into<f32>) -> Self {
self.threshold = threshold.into();
pub fn threshold(mut self, threshold: impl Into<OsThreshold<f32>>) -> Self {
let threshold = threshold.into().threshold();
self.threshold = threshold;
self
}

View File

@@ -22,9 +22,9 @@ impl Stroke {
};
#[inline]
pub fn new(width: impl Into<f32>, color: impl Into<Color32>) -> Self {
pub fn new(width: f32, color: impl Into<Color32>) -> Self {
Self {
width: width.into(),
width,
color: color.into(),
}
}
@@ -136,9 +136,9 @@ impl PathStroke {
};
#[inline]
pub fn new(width: impl Into<f32>, color: impl Into<Color32>) -> Self {
pub fn new(width: f32, color: impl Into<Color32>) -> Self {
Self {
width: width.into(),
width,
color: ColorMode::Solid(color.into()),
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`)
#[inline]
pub fn new_uv(
width: impl Into<f32>,
width: f32,
callback: impl Fn(Rect, Pos2) -> Color32 + Send + Sync + 'static,
) -> Self {
Self {
width: width.into(),
width,
color: ColorMode::UV(Arc::new(callback)),
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}");
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);
let viewport_data = self.containers_data.entry(container).or_insert_with(|| {
let mut res = Vec::new();