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.
Uh oh!
There was an error while loading. Please reload this page.
-
Should we have a naming guideline to avoid ambiguity from two crates providing extensions to the same type?
Background:
Extension traits, like
PathExtare a mechanism to provide additional functionality to an existing type.Options for using a trait
usethe<Type>Ext, allowing direct access to itsfunclikeval.func()<Type>Ext::func(val)rather thanval.func()If two crates provide a
<Type>Extfor 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-chainandfailurewhich both provideResultExt. In this case, the only reason I ran into it was comparing the libraries. I don't expect theResultExts 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