Is there a way to avoid `Arg<T>`
It is super annoying for auto completions to suggest divan get for literally everything.
/// Used by `#[divan::bench(args = ...)]` to enable polymorphism.
pub trait Arg<T> {
fn get(self) -> T;
}
impl<T> Arg<T> for T {
#[inline]
fn get(self) -> T {
self
}
}
I for one do not understand what your question is. Can you elaborate?
-
The code defines a trait
Arg<T>with a single methodget() -> T. This is a very generic trait that could potentially be used for any type. -
The
impl<T> Arg<T> for T { ... }block implements this trait for all typesT. This means that every single type in your codebase now has aget()method available. -
Modern IDEs use these trait implementations to provide auto-completion suggestions. Because
get()is now technically available on every type, the IDE dutifully suggests it whenever you type.after any variable, regardless of its actual type.
Perhaps we could change the signature? Something like
pub trait Arg<T> {
fn get(input: Self) -> T;
}
so we would have to call Arg::get(...) instead?
I think you are talking about the private module's Arg trait, here.
I think you are talking about the
privatemodule'sArgtrait, here.
yes. However, IDEs will still recommend it.
This is now fixed in v0.1.16.