Skip to content

Commit

Permalink
Make Rust Analyzer not recommend private::Arg::get
Browse files Browse the repository at this point in the history
When indexing slices, this `get` may be recommended instead of the
standard library's method.

Fixes #59.
  • Loading branch information
nvzqz committed Nov 1, 2024
1 parent e591be0 commit cc31e54
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ impl<T: ToString> ToStringHelper<'_, T> {

/// Used by `#[divan::bench(args = ...)]` to enable polymorphism.
pub trait Arg<T> {
fn get(self) -> T;
fn get(this: Self) -> T;
}

impl<T> Arg<T> for T {
#[inline]
fn get(self) -> T {
self
fn get(this: Self) -> T {
this
}
}

Expand All @@ -53,36 +53,36 @@ where
T: ToOwned,
{
#[inline]
fn get(self) -> &'a T {
self
fn get(this: Self) -> &'a T {
this
}
}

impl<'a> Arg<&'a str> for &'a String {
#[inline]
fn get(self) -> &'a str {
self
fn get(this: Self) -> &'a str {
this
}
}

impl<T: Copy> Arg<T> for &T {
#[inline]
fn get(self) -> T {
*self
fn get(this: Self) -> T {
*this
}
}

impl<T: Copy> Arg<T> for &&T {
#[inline]
fn get(self) -> T {
**self
fn get(this: Self) -> T {
**this
}
}

impl<T: Copy> Arg<T> for &&&T {
#[inline]
fn get(self) -> T {
***self
fn get(this: Self) -> T {
***this
}
}

Expand Down

0 comments on commit cc31e54

Please sign in to comment.