mirror of
https://codeberg.org/kaasboteram/zig-iterating.git
synced 2026-02-18 21:17:04 +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"),
|
.next = @hasDecl(Inner, "next"),
|
||||||
.peek = @hasDecl(Inner, "peek"),
|
.peek = @hasDecl(Inner, "peek"),
|
||||||
.reset = @hasDecl(Inner, "reset"),
|
.reset = @hasDecl(Inner, "reset"),
|
||||||
|
.size_hint = @hasDecl(Inner, "sizeHint"),
|
||||||
};
|
};
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
@ -97,6 +98,10 @@ pub fn Iterator(comptime Inner: type) type {
|
||||||
return self.inner.reset();
|
return self.inner.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn sizeHint(self: *const Self) ?usize {
|
||||||
|
return if (capabilities.size_hint) self.inner.sizeHint() else null;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn map(
|
pub fn map(
|
||||||
self: Self,
|
self: Self,
|
||||||
comptime T: type,
|
comptime T: type,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue