Naming guidelines for extension-Traits? #146
Replies: 3 comments
-
Name collisions can also be solved by |
Beta Was this translation helpful? Give feedback.
-
I think if the goal of the trait is just to augment standard types with additional functionality then the If a library is providing a trait that it expects others to implement or use in generic bounds then it's probably worth coming up with a better name than |
Beta Was this translation helpful? Give feedback.
-
I wonder if there's any downside in allowing people to come up with descriptive names regardless of the purpose while also considering |
Beta Was this translation helpful? Give feedback.
-
Should we have a naming guideline to avoid ambiguity from two crates providing extensions to the same type?
Background:
Extension traits, like
PathExt
are a mechanism to provide additional functionality to an existing type.Options for using a trait
use
the<Type>Ext
, allowing direct access to itsfunc
likeval.func()
<Type>Ext::func(val)
rather thanval.func()
If two crates provide a
<Type>Ext
for the same type, then you're only option is to go with the uglier route after running into this.I ran into this when experimenting with
error-chain
andfailure
which both provideResultExt
. In this case, the only reason I ran into it was comparing the libraries. I don't expect theResultExt
s to be mixed in code, so I didn't create an issue forfailure
. I assume there are other reasons to run into this though.Beta Was this translation helpful? Give feedback.
All reactions