Returning a simpler Iterator interface instead of a Map in Rust -
i'd write this:
fn fibs() -> std::iter::iterator<int> { homecoming std::iter::iterate((1i, 1i), |(a, b)| { (b, + b) }).map(|(a, _)| a) }
but if do, error:
error: explicit lifetime bound required fn fibs() -> std::iter::iterator<int> { ^^^^^^^^^^^^^^^^^^^^^^^^
if, instead write out total interface, compiles:
fn fibs() -> std::iter::map<'static, (int, int), int, std::iter::iterate<'static, (int, int)>> { homecoming std::iter::iterate((1i, 1i), |(a, b)| { (b, + b) }).map(|(a, _)| a) }
is there way homecoming simpler interface?
there not @ nowadays way homecoming abstract type such iterator<t>
, can’t assign type of variable (let x: iterator<uint>;
won’t compile same reasons).
this has been discussed , desired; when done in form fn fibs() -> impl iterator<uint>
, can’t yet.
rust
No comments:
Post a Comment