Add size hint support

This commit is contained in:
Luuk Machielse 2025-12-09 16:47:14 +01:00
parent bb3e7ffc6c
commit deb61d75ff

View file

@ -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,