Quantcast
Channel: How do you implement a trait for T where T: Foo OR Bar - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by nebulaeandstars for How do you implement a trait for T where T: Foo...

Turns out that there are some safety properties that need some serious thought before this can be a feature.The only real way to get close to what I was after is using the specialisation feature, which...

View Article



Answer by Chayim Friedman for How do you implement a trait for T where T: Foo...

If you use nightly, you can use the marker_trait_attr feature. It allows you to have overlapping impls for a trait that has the attribute #[marker]. Note that the trait should have no associated items...

View Article

How do you implement a trait for T where T: Foo OR Bar

In rust, you can automatically implement a trait for any type that implements some other combination of traits. Ie:impl<T: Foo + Bar> SomeTrait for T { some_function(&self) { /*...*/ }}What...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images