How to implement a Java equivalent of Rust's From trait?

Viewed 54

Rust has a convenient method to facilitate conversion between different types: the trait From (and Into) which defines an "interface" to convert an element to an other.

pub trait From<T> {
    fn from(T) -> Self;
}

Is it possible to implement an equivalent of the From trait with Java functional interfaces?

0 Answers
Related