mirror of
https://codeberg.org/kaasboteram/zig-iterating.git
synced 2025-12-15 09:43:14 +01:00
Add size hint support
This commit is contained in:
parent
bb3e7ffc6c
commit
deb61d75ff
1 changed files with 5 additions and 0 deletions
|
|
@ -78,6 +78,7 @@ pub fn Iterator(comptime Inner: type) type {
|
|||
.next = @hasDecl(Inner, "next"),
|
||||
.peek = @hasDecl(Inner, "peek"),
|
||||
.reset = @hasDecl(Inner, "reset"),
|
||||
.size_hint = @hasDecl(Inner, "sizeHint"),
|
||||
};
|
||||
|
||||
const Self = @This();
|
||||
|
|
@ -97,6 +98,10 @@ pub fn Iterator(comptime Inner: type) type {
|
|||
return self.inner.reset();
|
||||
}
|
||||
|
||||
pub fn sizeHint(self: *const Self) ?usize {
|
||||
return if (capabilities.size_hint) self.inner.sizeHint() else null;
|
||||
}
|
||||
|
||||
pub fn map(
|
||||
self: Self,
|
||||
comptime T: type,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue