Merged: Generator supporthttps://github.com/rust-lang/rust/pull/43076
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa#rustlang #programming
@grainloom What exactly does this add?
@lizardsquid coroutines, which means much simpler iteratorsexample in Lua:
local function range(a,b) return coroutine.wrap(function() for i = a, b or math.huge do coroutine.yield(i) end end)end
for i in range(0, 10000) do print(i)end
Python and JS have special syntaxes for it
@grainloom oh cool!
Computer Fairies is a Mastodon instance that aims to be as queer, friendly and furry as possible. We welcome all kinds of computer fairies!
@lizardsquid coroutines, which means much simpler iterators
example in Lua:
local function range(a,b)
return coroutine.wrap(function()
for i = a, b or math.huge do
coroutine.yield(i)
end
end)
end
for i in range(0, 10000) do
print(i)
end
Python and JS have special syntaxes for it