Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Dec 19, 2024
1 parent f6a4704 commit 75a0063
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ where
pub struct RuntimeGuard<'a>(Box<dyn BoxableGuard<'a> + 'a>);

trait BoxableGuard<'a> {}
impl<'a, T> BoxableGuard<'a> for T {}
impl<T> BoxableGuard<'_> for T {}

struct AppSettings {
multi_click_threshold: Duration,
Expand Down
12 changes: 6 additions & 6 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ impl<'context> Deref for EventContext<'context> {
}
}

impl<'context> DerefMut for EventContext<'context> {
impl DerefMut for EventContext<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.widget
}
Expand Down Expand Up @@ -573,7 +573,7 @@ pub struct GraphicsContext<'context, 'clip, 'gfx, 'pass> {
pub gfx: Exclusive<'context, Graphics<'clip, 'gfx, 'pass>>,
}

impl<'context, 'clip, 'gfx, 'pass> GraphicsContext<'context, 'clip, 'gfx, 'pass> {
impl<'clip, 'gfx, 'pass> GraphicsContext<'_, 'clip, 'gfx, 'pass> {
/// Returns a new instance that borrows from `self`.
pub fn borrowed(&mut self) -> GraphicsContext<'_, 'clip, 'gfx, 'pass> {
GraphicsContext {
Expand Down Expand Up @@ -749,15 +749,15 @@ impl Drop for GraphicsContext<'_, '_, '_, '_> {
}
}

impl<'context, 'clip, 'gfx, 'pass> Deref for GraphicsContext<'context, 'clip, 'gfx, 'pass> {
impl<'context> Deref for GraphicsContext<'context, '_, '_, '_> {
type Target = WidgetContext<'context>;

fn deref(&self) -> &Self::Target {
&self.widget
}
}

impl<'context, 'clip, 'gfx, 'pass> DerefMut for GraphicsContext<'context, 'clip, 'gfx, 'pass> {
impl DerefMut for GraphicsContext<'_, '_, '_, '_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.widget
}
Expand Down Expand Up @@ -842,7 +842,7 @@ impl<'context, 'clip, 'gfx, 'pass> LayoutContext<'context, 'clip, 'gfx, 'pass> {
}
}

impl<'context, 'clip, 'gfx, 'pass> AsEventContext for LayoutContext<'context, 'clip, 'gfx, 'pass> {
impl AsEventContext for LayoutContext<'_, '_, '_, '_> {
fn as_event_context(&mut self) -> EventContext<'_> {
self.graphics.as_event_context()
}
Expand All @@ -856,7 +856,7 @@ impl<'context, 'clip, 'gfx, 'pass> Deref for LayoutContext<'context, 'clip, 'gfx
}
}

impl<'context, 'clip, 'gfx, 'pass> DerefMut for LayoutContext<'context, 'clip, 'gfx, 'pass> {
impl DerefMut for LayoutContext<'_, '_, '_, '_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.graphics
}
Expand Down
8 changes: 4 additions & 4 deletions src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum RenderContext<'clip, 'gfx, 'pass> {
Clipped(ClipGuard<'clip, Renderer<'gfx, 'pass>>),
}

impl<'clip, 'gfx, 'pass> Graphics<'clip, 'gfx, 'pass> {
impl<'gfx, 'pass> Graphics<'_, 'gfx, 'pass> {
/// Returns a new graphics context for the given [`Renderer`].
#[must_use]
pub fn new(renderer: Renderer<'gfx, 'pass>) -> Self {
Expand Down Expand Up @@ -335,15 +335,15 @@ impl<'clip, 'gfx, 'pass> Graphics<'clip, 'gfx, 'pass> {
}
}

impl<'gfx, 'pass> Deref for Graphics<'_, 'gfx, 'pass> {
impl Deref for Graphics<'_, '_, '_> {
type Target = Kludgine;

fn deref(&self) -> &Self::Target {
&self.renderer
}
}

impl<'gfx, 'pass> DerefMut for Graphics<'_, 'gfx, 'pass> {
impl DerefMut for Graphics<'_, '_, '_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.renderer
}
Expand All @@ -360,7 +360,7 @@ impl<'gfx, 'pass> Deref for RenderContext<'_, 'gfx, 'pass> {
}
}

impl<'gfx, 'pass> DerefMut for RenderContext<'_, 'gfx, 'pass> {
impl DerefMut for RenderContext<'_, '_, '_> {
fn deref_mut(&mut self) -> &mut Self::Target {
match self {
RenderContext::Renderer(renderer) => renderer,
Expand Down
2 changes: 1 addition & 1 deletion src/styles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2607,7 +2607,7 @@ pub trait ProtoColor: Sized {
}
}

impl<'a> ProtoColor for &'a ColorSource {
impl ProtoColor for &'_ ColorSource {
fn hue(&self) -> OklabHue {
self.hue
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ macro_rules! impl_with_clone {
};
}

impl<'a, T> WithClone for &'a T
impl<T> WithClone for &'_ T
where
T: Clone,
{
Expand Down
24 changes: 12 additions & 12 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ where
}
}

impl<'a, T> DynamicMutexGuard<'a, T> {
impl<T> DynamicMutexGuard<'_, T> {
fn unlocked<R>(&mut self, while_unlocked: impl FnOnce() -> R) -> R {
let previous_state = self.dynamic.during_callback_state.lock().take();
let result = MutexGuard::unlocked(&mut self.guard, while_unlocked);
Expand All @@ -1554,7 +1554,7 @@ impl<'a, T> DynamicMutexGuard<'a, T> {
}
}

impl<'a, T> Drop for DynamicMutexGuard<'a, T> {
impl<T> Drop for DynamicMutexGuard<'_, T> {
fn drop(&mut self) {
let mut during_state = self.dynamic.during_callback_state.lock();
*during_state = None;
Expand All @@ -1563,14 +1563,14 @@ impl<'a, T> Drop for DynamicMutexGuard<'a, T> {
}
}

impl<'a, T> Deref for DynamicMutexGuard<'a, T> {
impl<T> Deref for DynamicMutexGuard<'_, T> {
type Target = State<T>;

fn deref(&self) -> &Self::Target {
&self.guard
}
}
impl<'a, T> DerefMut for DynamicMutexGuard<'a, T> {
impl<T> DerefMut for DynamicMutexGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.guard
}
Expand Down Expand Up @@ -2198,7 +2198,7 @@ enum DynamicOrOwnedGuard<'a, T> {
Owned(RefMut<'a, GenerationalValue<T>>),
OwnedRef(&'a mut GenerationalValue<T>),
}
impl<'a, T> DynamicOrOwnedGuard<'a, T> {
impl<T> DynamicOrOwnedGuard<'_, T> {
fn note_changed(&mut self) -> Option<ChangeCallbacks> {
match self {
Self::Dynamic(guard) => Some(guard.note_changed()),
Expand All @@ -2214,7 +2214,7 @@ impl<'a, T> DynamicOrOwnedGuard<'a, T> {
}
}

impl<'a, T> Deref for DynamicOrOwnedGuard<'a, T> {
impl<T> Deref for DynamicOrOwnedGuard<'_, T> {
type Target = GenerationalValue<T>;

fn deref(&self) -> &Self::Target {
Expand All @@ -2226,7 +2226,7 @@ impl<'a, T> Deref for DynamicOrOwnedGuard<'a, T> {
}
}

impl<'a, T> DerefMut for DynamicOrOwnedGuard<'a, T> {
impl<T> DerefMut for DynamicOrOwnedGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
match self {
Self::Dynamic(guard) => &mut guard.wrapped,
Expand Down Expand Up @@ -2272,15 +2272,15 @@ impl<T, const READONLY: bool> DynamicGuard<'_, T, READONLY> {
}
}

impl<'a, T, const READONLY: bool> Deref for DynamicGuard<'a, T, READONLY> {
impl<T, const READONLY: bool> Deref for DynamicGuard<'_, T, READONLY> {
type Target = T;

fn deref(&self) -> &Self::Target {
&self.guard.value
}
}

impl<'a, T> DerefMut for DynamicGuard<'a, T, false> {
impl<T> DerefMut for DynamicGuard<'_, T, false> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.accessed_mut = true;
&mut self.guard.value
Expand Down Expand Up @@ -2529,7 +2529,7 @@ impl<T> Drop for DynamicReader<T> {
#[must_use = "futures must be .await'ed to be executed"]
pub struct BlockUntilUpdatedFuture<'a, T>(&'a DynamicReader<T>);

impl<'a, T> Future for BlockUntilUpdatedFuture<'a, T> {
impl<T> Future for BlockUntilUpdatedFuture<'_, T> {
type Output = bool;

fn poll(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> {
Expand Down Expand Up @@ -3087,13 +3087,13 @@ impl<T> IntoValue<T> for T {
}
}

impl<'a> IntoValue<String> for &'a str {
impl IntoValue<String> for &'_ str {
fn into_value(self) -> Value<String> {
Value::Constant(self.to_owned())
}
}

impl<'a> IntoReadOnly<String> for &'a str {
impl IntoReadOnly<String> for &'_ str {
fn into_read_only(self) -> ReadOnly<String> {
ReadOnly::Constant(self.to_string())
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ where
/// A [`Menu`] that is preparing to be shown in an [`OverlayLayer`].
pub struct MenuOverlay<'a>(OverlayBuilder<'a>, OpenMenuHandle);

impl<'a> Overlayable for MenuOverlay<'a> {
impl Overlayable for MenuOverlay<'_> {
type Handle = OpenMenuHandle;

fn hide_on_unhover(self) -> Self {
Expand Down
5 changes: 2 additions & 3 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl<W> RunningWindow<W>
where
W: PlatformWindowImplementation,
{
#[allow(clippy::too_many_arguments)]
#[allow(clippy::too_many_arguments, clippy::ref_option)]
pub(crate) fn new(
window: W,
kludgine_id: KludgineId,
Expand Down Expand Up @@ -4688,8 +4688,7 @@ where
}

fn copy_buffer_aligned_bytes_per_row(width: u32) -> u32 {
(width + COPY_BYTES_PER_ROW_ALIGNMENT - 1) / COPY_BYTES_PER_ROW_ALIGNMENT
* COPY_BYTES_PER_ROW_ALIGNMENT
width.div_ceil(COPY_BYTES_PER_ROW_ALIGNMENT) * COPY_BYTES_PER_ROW_ALIGNMENT
}

/// An animated PNG recorder.
Expand Down

0 comments on commit 75a0063

Please sign in to comment.