-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed generated functions in trait-fns. (#7081)
feat(corelib): Iterator::enumerate (#7048) fix: Fix handling of --skip-first argument Update release_crates.sh (#7087) chore: orthographic correction in file if_else (#7088) prevents closure parameters from being declared as refrences (#7078) Refactored bounded_int_trim. (#7062) Added const for starknet types. (#6961) feat(corelib): Iterator::fold (#7084) feat(corelib): Iterator::advance_by (#7059) fix(corelib): Add the #[test] annotation to enumerate test (#7098) feat(corelib): storage vectors iterators (#6941) Extract ModuleHelper from const folding. (#7099) Added support for basic `Into`s in consts. (#7100) Removed taking value for `validate_literal`. (#7101) added closure params to semantic defs in lowering (#7085) Added support for `downcast` in constant context. (#7102) fix(corelib): Add the #[test] annotation to enumerate test (#7098)
- Loading branch information
1 parent
2d0c700
commit c6d03c5
Showing
40 changed files
with
1,233 additions
and
302 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/// An iterator that yields the current count and the element during iteration. | ||
/// | ||
/// This `struct` is created by the [`enumerate`] method on [`Iterator`]. See its | ||
/// documentation for more. | ||
/// | ||
/// [`enumerate`]: Iterator::enumerate | ||
/// [`Iterator`]: core::iter::Iterator | ||
#[must_use] | ||
#[derive(Drop, Clone, Debug)] | ||
pub struct Enumerate<I> { | ||
iter: I, | ||
count: usize, | ||
} | ||
|
||
pub fn enumerated_iterator<I>(iter: I) -> Enumerate<I> { | ||
Enumerate { iter, count: 0 } | ||
} | ||
|
||
impl EnumerateIterator< | ||
I, T, +Iterator<I>[Item: T], +Destruct<I>, +Destruct<T>, | ||
> of Iterator<Enumerate<I>> { | ||
type Item = (usize, T); | ||
|
||
/// # Overflow Behavior | ||
/// | ||
/// The method does no guarding against overflows, so enumerating more than | ||
/// `Bounded::<usize>::MAX` elements will always panic. | ||
/// | ||
/// [`Bounded`]: core::num::traits::Bounded | ||
/// | ||
/// # Panics | ||
/// | ||
/// Will panic if the index of the element overflows a `usize`. | ||
#[inline] | ||
fn next(ref self: Enumerate<I>) -> Option<Self::Item> { | ||
let a = self.iter.next()?; | ||
let i = self.count; | ||
self.count += 1; | ||
Option::Some((i, a)) | ||
} | ||
} |
Oops, something went wrong.