Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix array repetition operand evaluation #530

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

scrabsha
Copy link
Contributor

@scrabsha scrabsha commented Nov 4, 2024

It turns out that [<repeated>; <length>] evaluates <repeated> only one time, as seen in the following example:

fn main() {
    let mut counter = 0;
    [{
        counter += 1;
    }; 9];
    assert_eq!(counter, 1);
}
Playground link

This PR updates the doc in order to match this behavior.

It turns out that `[<repeated>; <length>]` evaluates `<repeated>` only one time,
as seen in the following example:

```rust
fn main() {
    let mut counter = 0;
    [{
        counter += 1;
    }; 9];
    assert_eq!(counter, 1);
}
```

###### [Playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b7ca3de9ba64675238380acae97fde37)

This PR updates the doc in order to match this behavior.
@Veykril
Copy link
Member

Veykril commented Nov 4, 2024

Thanks!
bors merge

@bors-ferrocene
Copy link
Contributor

bors-ferrocene bot commented Nov 4, 2024

Build succeeded:

@bors-ferrocene bors-ferrocene bot merged commit 7af39ec into ferrocene:main Nov 4, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants