Relative Content

Tag Archive for rusttraits

Kotlin scope functions in Rust?

Studying Rust and Kotlin at the moment, I wonder whether something as neat as Kotlin’s Scope functions (let, apply, run, etc.) could be / are implemented in Rust?

Using Option as associated type in trait that returns reference to it

I have a trait with an associated type Value, and two methods. One returns &Self::Value and the other receives Self::Value. This trait is implemented for several types, but I want to implement it for one type in particular where type Value = Option<...>. This creates a problem, as demonstrated below (playground):