GitXplorerGitXplorer
u

rust-fake-yield

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
f2bce76d3ee5667e203349838daf4e76900c29f7

either testcase

uuntitaker committed 4 years ago
Unverified
3326a6dc0eb4ab17b36c072bfecea738cbf59292

implement simple for loop

uuntitaker committed 6 years ago
Unverified
bd137c726b3e296175199c963756958671f20ee3

doc: Readme

uuntitaker committed 6 years ago
Unverified
eef4564c4807d8386109fb585252dfd667a46dbb

rewrite as proc-macro

uuntitaker committed 6 years ago
Unverified
da69a8a645ee0ddb964557f98068a9481e4f625b

init

uuntitaker committed 6 years ago

README

The README file for this repository.

fake-yield

Python's yield implemented for Rust.

fn to_html_stream<'a>(xs: impl IntoIterator<Item = &'a str>) -> impl Iterator<Item = &'a str> {
    fake_yield! {{
        _yield!("<ul>\n");
        for x in xs {
            _yield!("<li>");
            _yield!(x);  // Don't try this at home
            _yield!("</li>\n");
        }
        _yield!("</ul>");
    }}
}

This is very much work-in-progress:

  • Other kinds of loops don't work.
  • If you use break or continue, weird things will happen.

Check tests/ for more examples.

Probably affects performance.