mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 22:53:15 -04:00
chore: fix clippy issues
This commit is contained in:
@@ -1152,7 +1152,7 @@ mod tests {
|
||||
#[test]
|
||||
fn ensure_attrs_do_not_panic() {
|
||||
foreach_event!(|event: event::Event<()>| {
|
||||
let _ = format!("{:?}", event);
|
||||
let _ = format!("{event:?}");
|
||||
});
|
||||
let _ = event::StartCause::Init.clone();
|
||||
|
||||
|
||||
@@ -165,7 +165,6 @@
|
||||
//! [`Window`]: window::Window
|
||||
//! [`WindowId`]: window::WindowId
|
||||
//! [`WindowAttributes`]: window::WindowAttributes
|
||||
//! [window_new]: window::Window::new
|
||||
//! [`create_window`]: event_loop::ActiveEventLoop::create_window
|
||||
//! [`Window::id()`]: window::Window::id
|
||||
//! [`WindowEvent`]: event::WindowEvent
|
||||
@@ -185,6 +184,9 @@
|
||||
// doc
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide), doc(cfg_hide(doc, docsrs)))]
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
#![warn(clippy::uninlined_format_args)]
|
||||
// TODO: wasm-binding needs to be updated for that to be resolved, for now just silence it.
|
||||
#![cfg_attr(web_platform, allow(unknown_lints, wasm_c_abi))]
|
||||
|
||||
#[cfg(feature = "rwh_04")]
|
||||
pub use rwh_04 as raw_window_handle_04;
|
||||
|
||||
@@ -51,19 +51,19 @@ pub trait EventLoopExtPumpEvents {
|
||||
/// buffered and handled outside of Winit include:
|
||||
/// - `RedrawRequested` events, used to schedule rendering.
|
||||
///
|
||||
/// macOS for example uses a `drawRect` callback to drive rendering
|
||||
/// within applications and expects rendering to be finished before
|
||||
/// the `drawRect` callback returns.
|
||||
/// macOS for example uses a `drawRect` callback to drive rendering
|
||||
/// within applications and expects rendering to be finished before
|
||||
/// the `drawRect` callback returns.
|
||||
///
|
||||
/// For portability it's strongly recommended that applications should
|
||||
/// keep their rendering inside the closure provided to Winit.
|
||||
/// For portability it's strongly recommended that applications should
|
||||
/// keep their rendering inside the closure provided to Winit.
|
||||
/// - Any lifecycle events, such as `Suspended` / `Resumed`.
|
||||
///
|
||||
/// The handling of these events needs to be synchronized with the
|
||||
/// operating system and it would never be appropriate to buffer a
|
||||
/// notification that your application has been suspended or resumed and
|
||||
/// then handled that later since there would always be a chance that
|
||||
/// other lifecycle events occur while the event is buffered.
|
||||
/// The handling of these events needs to be synchronized with the
|
||||
/// operating system and it would never be appropriate to buffer a
|
||||
/// notification that your application has been suspended or resumed and
|
||||
/// then handled that later since there would always be a chance that
|
||||
/// other lifecycle events occur while the event is buffered.
|
||||
///
|
||||
/// ## Supported Platforms
|
||||
///
|
||||
|
||||
@@ -63,8 +63,8 @@ pub trait EventLoopExtRunOnDemand {
|
||||
/// are delivered via callbacks based on an event loop that is internal to the browser itself.
|
||||
/// - **iOS:** It's not possible to stop and start an `UIApplication` repeatedly on iOS.
|
||||
#[cfg_attr(not(web_platform), doc = "[^1]: `spawn()` is only available on `wasm` platforms.")]
|
||||
#[rustfmt::skip]
|
||||
///
|
||||
#[rustfmt::skip]
|
||||
/// [`exit()`]: ActiveEventLoop::exit()
|
||||
/// [`set_control_flow()`]: ActiveEventLoop::set_control_flow()
|
||||
fn run_app_on_demand<A: ApplicationHandler<Self::UserEvent>>(
|
||||
|
||||
@@ -190,7 +190,7 @@ declare_class!(
|
||||
// Pass -delta so that action is reversed
|
||||
(TouchPhase::Cancelled, -recognizer.scale())
|
||||
}
|
||||
state => panic!("unexpected recognizer state: {:?}", state),
|
||||
state => panic!("unexpected recognizer state: {state:?}"),
|
||||
};
|
||||
|
||||
let gesture_event = EventWrapper::StaticEvent(Event::WindowEvent {
|
||||
@@ -249,7 +249,7 @@ declare_class!(
|
||||
// Pass -delta so that action is reversed
|
||||
(TouchPhase::Cancelled, -recognizer.rotation())
|
||||
}
|
||||
state => panic!("unexpected recognizer state: {:?}", state),
|
||||
state => panic!("unexpected recognizer state: {state:?}"),
|
||||
};
|
||||
|
||||
// Make delta negative to match macos, convert to degrees
|
||||
@@ -300,7 +300,7 @@ declare_class!(
|
||||
// Pass -delta so that action is reversed
|
||||
(TouchPhase::Cancelled, -last_pan.x, -last_pan.y)
|
||||
}
|
||||
state => panic!("unexpected recognizer state: {:?}", state),
|
||||
state => panic!("unexpected recognizer state: {state:?}"),
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ fn push_display(buffer: &mut Vec<u8>, display: &impl std::fmt::Display) {
|
||||
}
|
||||
}
|
||||
|
||||
write!(Writer { buffer }, "{}", display).unwrap();
|
||||
write!(Writer { buffer }, "{display}").unwrap();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -850,24 +850,24 @@ pub enum X11Error {
|
||||
impl fmt::Display for X11Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
X11Error::Xlib(e) => write!(f, "Xlib error: {}", e),
|
||||
X11Error::Connect(e) => write!(f, "X11 connection error: {}", e),
|
||||
X11Error::Connection(e) => write!(f, "X11 connection error: {}", e),
|
||||
X11Error::XidsExhausted(e) => write!(f, "XID range exhausted: {}", e),
|
||||
X11Error::GetProperty(e) => write!(f, "Failed to get X property {}", e),
|
||||
X11Error::X11(e) => write!(f, "X11 error: {:?}", e),
|
||||
X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {}", s),
|
||||
X11Error::Xlib(e) => write!(f, "Xlib error: {e}"),
|
||||
X11Error::Connect(e) => write!(f, "X11 connection error: {e}"),
|
||||
X11Error::Connection(e) => write!(f, "X11 connection error: {e}"),
|
||||
X11Error::XidsExhausted(e) => write!(f, "XID range exhausted: {e}"),
|
||||
X11Error::GetProperty(e) => write!(f, "Failed to get X property {e}"),
|
||||
X11Error::X11(e) => write!(f, "X11 error: {e:?}"),
|
||||
X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {s}"),
|
||||
X11Error::InvalidActivationToken(s) => write!(
|
||||
f,
|
||||
"Invalid activation token: {}",
|
||||
std::str::from_utf8(s).unwrap_or("<invalid utf8>")
|
||||
),
|
||||
X11Error::MissingExtension(s) => write!(f, "Missing X11 extension: {}", s),
|
||||
X11Error::MissingExtension(s) => write!(f, "Missing X11 extension: {s}"),
|
||||
X11Error::NoSuchVisual(visualid) => {
|
||||
write!(f, "Could not find a matching X11 visual for ID `{:x}`", visualid)
|
||||
write!(f, "Could not find a matching X11 visual for ID `{visualid:x}`")
|
||||
},
|
||||
X11Error::XsettingsParse(err) => {
|
||||
write!(f, "Failed to parse xsettings: {:?}", err)
|
||||
write!(f, "Failed to parse xsettings: {err:?}")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ impl XConnection {
|
||||
fn new_xsettings_screen(xcb: &XCBConnection, default_screen: usize) -> Option<xproto::Atom> {
|
||||
// Fetch the _XSETTINGS_S[screen number] atom.
|
||||
let xsettings_screen = xcb
|
||||
.intern_atom(false, format!("_XSETTINGS_S{}", default_screen).as_bytes())
|
||||
.intern_atom(false, format!("_XSETTINGS_S{default_screen}").as_bytes())
|
||||
.ok()?
|
||||
.reply()
|
||||
.ok()?
|
||||
|
||||
@@ -420,7 +420,7 @@ impl Window {
|
||||
window::ResizeDirection::West => "L",
|
||||
};
|
||||
self.window_socket
|
||||
.write(format!("D,{}", arg).as_bytes())
|
||||
.write(format!("D,{arg}").as_bytes())
|
||||
.map_err(|err| error::ExternalError::Os(os_error!(OsError::new(err))))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1864,14 +1864,14 @@ impl ActivationToken {
|
||||
/// won't get focused automatically), but won't yield any errors.
|
||||
///
|
||||
/// To obtain a valid token, use
|
||||
#[cfg_attr(any(x11_platform, wayland_platform, docsrs), doc = " [`request_activation_token`].")]
|
||||
#[cfg_attr(
|
||||
any(x11_platform, wayland_platform, docsrs),
|
||||
doc = " [`request_activation_token`](crate::platform::startup_notify::WindowExtStartupNotify::request_activation_token)."
|
||||
)]
|
||||
#[cfg_attr(
|
||||
not(any(x11_platform, wayland_platform, docsrs)),
|
||||
doc = " `request_activation_token`."
|
||||
)]
|
||||
///
|
||||
#[rustfmt::skip]
|
||||
/// [`request_activation_token`]: crate::platform::startup_notify::WindowExtStartupNotify::request_activation_token
|
||||
pub fn from_raw(token: String) -> Self {
|
||||
Self { token }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user