mirror of
https://github.com/janet-lang/janet
synced 2025-11-07 02:53:02 +00:00
Allow calling next on abstracts.
This will allow the creation of infinte streams, low cost generators, etc.
This commit is contained in:
@@ -87,6 +87,12 @@ Janet janet_next(Janet ds, Janet key) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JANET_ABSTRACT: {
|
||||
JanetAbstract abst = janet_unwrap_abstract(ds);
|
||||
const JanetAbstractType *at = janet_abstract_type(abst);
|
||||
if (NULL == at->next) break;
|
||||
return at->next(abst, key);
|
||||
}
|
||||
}
|
||||
return janet_wrap_nil();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user