You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current behavior:
While working on iterators I wanted to implement advance_by which is basically a loop of next. As such the implementation is the same for all types, and I was writing the default trait impl as:
/// An iterator over a collection of values.pubtraitIterator<T>{/// The type of the elements being iterated over.typeItem;/// Advance the iterator and return the next value.fnnext(refself:T) -> Option<Self::Item>;fnadvance_by(refself:T,n:usize) -> Result<(),NonZero<usize>>{letmut res = Result::Ok(());for i in0..n {ifSelf::next(ref self).is_none(){
res = Result::Err((n - i).try_into().unwrap());break;}};
res
}}
However, this breaks compilation with:
thread 'scarb compile tmp-lk338q382tp00' panicked at /Users/runner/.cargo/git/checkouts/cairo-f086c7e6d4098a68/809dfef/crates/cairo-lang-semantic/src/substitution.rs:493:21:
assertion `left == right` failed
left: TraitId(0)
right: TraitId(7)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at scarb/src/ops/compile.rs:197:14:
Compiler thread has panicked.: Any { .. }
Expected behavior:
This should compile successfully or fail compilation but without a panic
Steps to reproduce:
Create an isolated cairo file with:
/// An iterator over a collection of values.pubtraitIterator2<T>{/// The type of the elements being iterated over.typeItem;/// Advance the iterator and return the next value.fnnext(refself:T) -> Option<Self::Item>;fnadvance_by(refself:T,n:usize) -> Result<(),NonZero<usize>>{letmut res = Result::Ok(());for i in0..n {ifSelf::next(ref self).is_none(){
res = Result::Err((n - i).try_into().unwrap());break;}};
res
}}
without advance_by - runs fine. with, panics
The text was updated successfully, but these errors were encountered:
Bug Report
Cairo version:
2.9.2
Current behavior:
While working on iterators I wanted to implement
advance_by
which is basically a loop ofnext
. As such the implementation is the same for all types, and I was writing the default trait impl as:However, this breaks compilation with:
Expected behavior:
This should compile successfully or fail compilation but without a panic
Steps to reproduce:
Create an isolated cairo file with:
without
advance_by
- runs fine. with, panicsThe text was updated successfully, but these errors were encountered: