#Why are these conflicting impls?

10 messages · Page 1 of 1 (latest)

midnight flower
#

The error seems a bit amiguous

fiery citrus
#

All types automatically implement From on themselves. Your custom From where I: Into<u64> overlaps, because Align: Into<u64> - therefore the compiler doesn't know whether From<Align> for Align should use the blanket impl or your impl

midnight flower
#

Oh, hmm

#

I see

#

How would I work around this implementation issue?

#

I suppose I can just not implement .into

fiery citrus
#

That's probably the fastest way - you can instead provide an inherent method for it

#

The alternative is to not provide the blanket From, and only implement From<u64> - any method that cares can accept I: Into<u64> then just call i.into().into()

#

(Or to avoid possible type inference issues, u64::from(i).into())

midnight flower
#

I see