derive_more icon indicating copy to clipboard operation
derive_more copied to clipboard

Use Into<_> for datatypes when deriving Constructor

Open Susurrus opened this issue 8 years ago • 2 comments
trafficstars

To improve ergonomics, instead of requiring specific datatypes instead use Into<_> for those datatypes. So instead of something like

impl MyInts {
    fn new(__0: i32, __1: i32) -> MyInts {
        MyInts(__0, __1)
    }
}

something like

impl MyInts {
    fn new<T: Into<i32>, U: Into<i32>>(__0: T, __1: U) -> MyInts {
        MyInts(__0.into(), __1.into())
    }
}

Susurrus avatar Jun 01 '17 18:06 Susurrus

Good suggestion, same goes for From derivation. Not sure when I find the time to do this though.

JelteF avatar Jun 01 '17 23:06 JelteF

Maybe it's worth reaching out to people on This Week in Rust on their Calls for Participation section. If you tag bugs as easy with enough of a description, might be able to get some new blood in here writing PRs!

Susurrus avatar Jun 01 '17 23:06 Susurrus