Skip to content

yield without value from a gen block #123614

Description

@Jules-Bertholet

I tried this code:

// edition 2024
#![feature(gen_blocks)]
fn foo() -> impl Iterator {
    gen {
        yield;
    }
}

I expected to see this happen: The gen blocks RFC does not specify the behavior of bare yield (without an argument). There are three possible choices, each with good reasons for and against:

  • Reject it entirely
  • Return None from Iterator::next()
  • Equivalent to yield ()

Instead, this happened: The current behavior is that of yield ().

Meta

rustc --version:

1.79.0-nightly (2024-04-06 aa1c45908df252a5b0c1)

cc #117078

@rustbot label F-gen_blocks

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.F-gen_blocks`gen {}` expressions that produce `Iterator`s

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions