Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I wanted to concertize my idea from #270 into some code. Instead of creating additional
from_i*
methods I propose usingInto<i64>
forfrom_i64
. Leveraging the trait system here runs into some non-obvious issues.from_u64
withInto<u64>
. Well, it's allowed but then callingInt::from_u64(1)
is a typing error because the type of1
here is ambigious(under-constrained). When an integer literal has an ambigious type, it defaults toi32
and therefore fails. This is fine forInto<i64>
sincei32
implementsInto<i64>
impl<'ctx, T: Into<i64>> Div<T> for Int<'ctx> {
because there are other implementations ofDiv
forInt<'ctx>
that the compiler can't prove to not overlap(either currently or in some future version which would lead to breakage). Maybe there is something I'm missing or some kind of nightly negative trait impls that one could use.ops.rs
already heavily makes use of macros so I figure it's find to make a new macro that generalizes over the valid integer types:u64, i64, i32, i16, i8