Skip to content

Redundant type parameters in deref methods #11

@wackbyte

Description

@wackbyte

Currently, pipe_deref is defined like so:

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where
    Self: Deref<Target = T>,
    T: 'a + ?Sized,
    R: 'a + Sized,
{ ... }

The type parameter T here is redundant as it is essentially an alias for <Self as Deref>::Target.
pipe_deref can be rewritten as:

fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R
where
    Self: Deref,
    Self::Target: 'a,
    R: 'a + Sized,
{ ... }

(This goes for tap_deref as well as these methods' mutable counterparts.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions