mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 14:20:04 -04:00
Enable and fix a bunch more lints
This commit is contained in:
@@ -51,7 +51,7 @@ struct ContextImpl {
|
||||
repaint_after: std::time::Duration,
|
||||
/// While positive, keep requesting repaints. Decrement at the end of each frame.
|
||||
repaint_requests: u32,
|
||||
request_repaint_callbacks: Option<Box<dyn Fn() + Send + Sync>>,
|
||||
request_repaint_callback: Option<Box<dyn Fn() + Send + Sync>>,
|
||||
requested_repaint_last_frame: bool,
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ impl Context {
|
||||
// request two frames of repaint, just to cover some corner cases (frame delays):
|
||||
let mut ctx = self.write();
|
||||
ctx.repaint_requests = 2;
|
||||
if let Some(callback) = &ctx.request_repaint_callbacks {
|
||||
if let Some(callback) = &ctx.request_repaint_callback {
|
||||
(callback)();
|
||||
}
|
||||
}
|
||||
@@ -611,9 +611,11 @@ impl Context {
|
||||
/// For integrations: this callback will be called when an egui user calls [`Self::request_repaint`].
|
||||
///
|
||||
/// This lets you wake up a sleeping UI thread.
|
||||
///
|
||||
/// Note that only one callback can be set. Any new call overrides the previous callback.
|
||||
pub fn set_request_repaint_callback(&self, callback: impl Fn() + Send + Sync + 'static) {
|
||||
let callback = Box::new(callback);
|
||||
self.write().request_repaint_callbacks = Some(callback);
|
||||
self.write().request_repaint_callback = Some(callback);
|
||||
}
|
||||
|
||||
/// Tell `egui` which fonts to use.
|
||||
|
||||
@@ -316,19 +316,19 @@ use crate::Id;
|
||||
///
|
||||
/// // `b` associated with an f64 and a `&'static str`
|
||||
/// map.insert_persisted(b, 13.37);
|
||||
/// map.insert_temp(b, "Hello World".to_string());
|
||||
/// map.insert_temp(b, "Hello World".to_owned());
|
||||
///
|
||||
/// // we can retrieve all four values:
|
||||
/// assert_eq!(map.get_temp::<f64>(a), Some(3.14));
|
||||
/// assert_eq!(map.get_temp::<i32>(a), Some(42));
|
||||
/// assert_eq!(map.get_temp::<f64>(b), Some(13.37));
|
||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_owned()));
|
||||
///
|
||||
/// // we can retrieve them like so also:
|
||||
/// assert_eq!(map.get_persisted::<f64>(a), Some(3.14));
|
||||
/// assert_eq!(map.get_persisted::<i32>(a), Some(42));
|
||||
/// assert_eq!(map.get_persisted::<f64>(b), Some(13.37));
|
||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_owned()));
|
||||
/// ```
|
||||
#[derive(Clone, Debug, Default)]
|
||||
// We store use `id XOR typeid` as a key, so we don't need to hash again!
|
||||
@@ -574,19 +574,19 @@ fn test_two_id_x_two_types() {
|
||||
|
||||
// `b` associated with an f64 and a `&'static str`
|
||||
map.insert_persisted(b, 13.37);
|
||||
map.insert_temp(b, "Hello World".to_string());
|
||||
map.insert_temp(b, "Hello World".to_owned());
|
||||
|
||||
// we can retrieve all four values:
|
||||
assert_eq!(map.get_temp::<f64>(a), Some(3.14));
|
||||
assert_eq!(map.get_temp::<i32>(a), Some(42));
|
||||
assert_eq!(map.get_temp::<f64>(b), Some(13.37));
|
||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_owned()));
|
||||
|
||||
// we can retrieve them like so also:
|
||||
assert_eq!(map.get_persisted::<f64>(a), Some(3.14));
|
||||
assert_eq!(map.get_persisted::<i32>(a), Some(42));
|
||||
assert_eq!(map.get_persisted::<f64>(b), Some(13.37));
|
||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -249,7 +249,7 @@ impl<'a> Widget for DragValue<'a> {
|
||||
.then(|| drag_state.last_dragged_value)
|
||||
.flatten();
|
||||
let stored_value = stored_value.unwrap_or(value);
|
||||
let stored_value = stored_value + delta_value as f64;
|
||||
let stored_value = stored_value + delta_value;
|
||||
|
||||
let aim_delta = aim_rad * speed;
|
||||
let rounded_new_value = emath::smart_aim::best_in_range_f64(
|
||||
|
||||
@@ -837,8 +837,7 @@ impl PlotItem for Points {
|
||||
stem_stroke.width *= 2.0;
|
||||
}
|
||||
|
||||
let y_reference =
|
||||
stems.map(|y| transform.position_from_value(&Value::new(0.0, y)).y as f32);
|
||||
let y_reference = stems.map(|y| transform.position_from_value(&Value::new(0.0, y)).y);
|
||||
|
||||
series
|
||||
.values
|
||||
@@ -1619,7 +1618,7 @@ fn add_rulers_and_text(
|
||||
|
||||
// Text
|
||||
let text = text.unwrap_or({
|
||||
let mut text = elem.name().to_string(); // could be empty
|
||||
let mut text = elem.name().to_owned(); // could be empty
|
||||
|
||||
if show_values {
|
||||
text.push_str(&elem.default_values_format(plot.transform));
|
||||
|
||||
@@ -178,7 +178,7 @@ impl LegendWidget {
|
||||
.filter(|item| !item.name().is_empty())
|
||||
.for_each(|item| {
|
||||
entries
|
||||
.entry(item.name().to_string())
|
||||
.entry(item.name().to_owned())
|
||||
.and_modify(|entry| {
|
||||
if entry.color != item.color() {
|
||||
// Multiple items with different colors
|
||||
|
||||
@@ -370,7 +370,7 @@ impl Plot {
|
||||
/// if !name.is_empty() {
|
||||
/// format!("{}: {:.*}%", name, 1, value.y)
|
||||
/// } else {
|
||||
/// "".to_string()
|
||||
/// "".to_owned()
|
||||
/// }
|
||||
/// })
|
||||
/// .show(ui, |plot_ui| plot_ui.line(line));
|
||||
|
||||
@@ -108,7 +108,7 @@ impl Widget for ProgressBar {
|
||||
|
||||
if animate {
|
||||
let n_points = 20;
|
||||
let start_angle = ui.input().time as f64 * 360f64.to_radians();
|
||||
let start_angle = ui.input().time * std::f64::consts::TAU;
|
||||
let end_angle = start_angle + 240f64.to_radians() * ui.input().time.sin();
|
||||
let circle_radius = rounding - 2.0;
|
||||
let points: Vec<Pos2> = (0..n_points)
|
||||
|
||||
@@ -38,7 +38,7 @@ impl Widget for Spinner {
|
||||
|
||||
let radius = (rect.height() / 2.0) - 2.0;
|
||||
let n_points = 20;
|
||||
let start_angle = ui.input().time as f64 * 360f64.to_radians();
|
||||
let start_angle = ui.input().time * std::f64::consts::TAU;
|
||||
let end_angle = start_angle + 240f64.to_radians() * ui.input().time.sin();
|
||||
let points: Vec<Pos2> = (0..n_points)
|
||||
.map(|i| {
|
||||
|
||||
Reference in New Issue
Block a user