mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Enable the clippy::std_instead_of_core lint (#8394)
Prefer `core::` over `std::` where either work * Part of https://github.com/emilk/egui/issues/5735
This commit is contained in:
@@ -344,7 +344,7 @@ impl AppRunner {
|
||||
|
||||
/// Paint the results of the last call to [`Self::logic`].
|
||||
pub fn paint(&mut self) {
|
||||
let clipped_primitives = std::mem::take(&mut self.clipped_primitives);
|
||||
let clipped_primitives = core::mem::take(&mut self.clipped_primitives);
|
||||
|
||||
if let Some(clipped_primitives) = clipped_primitives {
|
||||
let mut screenshot_commands = vec![];
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
use std::{
|
||||
future::Future,
|
||||
path::{Path, PathBuf},
|
||||
pin::Pin,
|
||||
};
|
||||
use core::{future::Future, pin::Pin};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct WebFile {
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn primary_touch_pos(
|
||||
event: &web_sys::TouchEvent,
|
||||
) -> Option<(egui::Pos2, web_sys::Touch)> {
|
||||
// On touchend we don't get anything in `touches`, but we still get `changed_touches`, so include those:
|
||||
let all_touches: Vec<_> = std::iter::chain(
|
||||
let all_touches: Vec<_> = core::iter::chain(
|
||||
(0..event.touches().length()).filter_map(|i| event.touches().get(i)),
|
||||
(0..event.changed_touches().length()).filter_map(|i| event.changed_touches().get(i)),
|
||||
)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! The text agent is a hidden `<input>` element used to capture
|
||||
//! IME and mobile keyboard input events.
|
||||
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use core::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
@@ -366,7 +367,7 @@ impl InputState {
|
||||
&self,
|
||||
text: &str,
|
||||
prefix_len_chars: usize,
|
||||
) -> Option<std::ops::Range<usize>> {
|
||||
) -> Option<core::ops::Range<usize>> {
|
||||
let selection_start = self.input.selection_start().unwrap_or(None)? as usize;
|
||||
let selection_end = self.input.selection_end().unwrap_or(None)? as usize;
|
||||
|
||||
@@ -444,7 +445,7 @@ impl InputState {
|
||||
}
|
||||
|
||||
fn longest_common_prefix_length(a: &str, b: &str) -> usize {
|
||||
std::iter::zip(a.chars(), b.chars())
|
||||
core::iter::zip(a.chars(), b.chars())
|
||||
.take_while(|(a, b)| a == b)
|
||||
.count()
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ impl WebPainter for WebPainterWgpu {
|
||||
// Submit the commands: both the main buffer and user-defined ones.
|
||||
render_state
|
||||
.queue
|
||||
.submit(std::iter::chain(user_cmd_bufs, [encoder.finish()]));
|
||||
.submit(core::iter::chain(user_cmd_bufs, [encoder.finish()]));
|
||||
|
||||
if let Some((frame, capture_buffer)) = frame_and_capture_buffer {
|
||||
if let Some(capture_buffer) = capture_buffer
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use core::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
@@ -107,7 +108,7 @@ impl WebRunner {
|
||||
|
||||
fn unsubscribe_from_all_events(&self) {
|
||||
let events_to_unsubscribe: Vec<_> =
|
||||
std::mem::take(&mut *self.events_to_unsubscribe.borrow_mut());
|
||||
core::mem::take(&mut *self.events_to_unsubscribe.borrow_mut());
|
||||
|
||||
if !events_to_unsubscribe.is_empty() {
|
||||
log::debug!("Unsubscribing from {} events", events_to_unsubscribe.len());
|
||||
@@ -139,7 +140,7 @@ impl WebRunner {
|
||||
|
||||
/// Returns `None` if there has been a panic, or if we have been destroyed.
|
||||
/// In that case, just return to JS.
|
||||
pub(crate) fn try_lock(&self) -> Option<std::cell::RefMut<'_, AppRunner>> {
|
||||
pub(crate) fn try_lock(&self) -> Option<core::cell::RefMut<'_, AppRunner>> {
|
||||
if self.panic_handler.has_panicked() {
|
||||
// Unsubscribe from all events so that we don't get any more callbacks
|
||||
// that will try to access the poisoned runner.
|
||||
@@ -147,7 +148,7 @@ impl WebRunner {
|
||||
None
|
||||
} else {
|
||||
let lock = self.app_runner.try_borrow_mut().ok()?;
|
||||
std::cell::RefMut::filter_map(lock, |lock| -> Option<&mut AppRunner> { lock.as_mut() })
|
||||
core::cell::RefMut::filter_map(lock, |lock| -> Option<&mut AppRunner> { lock.as_mut() })
|
||||
.ok()
|
||||
}
|
||||
}
|
||||
@@ -158,9 +159,9 @@ impl WebRunner {
|
||||
/// and return `None` if this runner has panicked.
|
||||
pub fn app_mut<ConcreteApp: 'static + App>(
|
||||
&self,
|
||||
) -> Option<std::cell::RefMut<'_, ConcreteApp>> {
|
||||
) -> Option<core::cell::RefMut<'_, ConcreteApp>> {
|
||||
self.try_lock()
|
||||
.map(|lock| std::cell::RefMut::map(lock, |runner| runner.app_mut::<ConcreteApp>()))
|
||||
.map(|lock| core::cell::RefMut::map(lock, |runner| runner.app_mut::<ConcreteApp>()))
|
||||
}
|
||||
|
||||
/// Convenience function to reduce boilerplate and ensure that all event handlers
|
||||
|
||||
Reference in New Issue
Block a user