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

Result in example file change when removing assert_eq!() #213

Closed
veryhumanprogrammer opened this issue Sep 17, 2022 · 2 comments
Closed

Comments

@veryhumanprogrammer
Copy link

veryhumanprogrammer commented Sep 17, 2022

I noticed that removing the assert_eq!() in the basics.rs example on line 80 caused the printed values to change.
Not sure if this is intended, but it doesn't seem like it. I'm quite new to Rust so maybe I missed something, but I am unable to explain why this happens.

This is the part of the code in basic.rs I mean

    for idx in 0..WORK_SIZE {
        if idx < RESULTS_TO_PRINT {
            println!("source[{idx}]: {:.03}, \t coeff: {}, \tresult[{idx}]: {}",
            vec_source[idx], COEFF, results[idx], idx = idx);
        }
        assert_eq!(vec_source[idx] * COEFF, vec_result[idx]);
    }

If I change it to this, the printed values change

    for idx in 0..WORK_SIZE {
        if idx < RESULTS_TO_PRINT {
            println!("source[{idx}]: {:.03}, \t coeff: {}, \tresult[{idx}]: {}",
            vec_source[idx], COEFF, results[idx], idx = idx);
        }
    }

However, if I change it to this it doesn't change

    for idx in 0..WORK_SIZE {
        if idx < RESULTS_TO_PRINT {
            println!("source[{idx}]: {:.03}, \t coeff: {}, \tresult[{idx}]: {}",
            vec_source[idx], COEFF, results[idx], idx = idx);
        }
        let test = vec_source[0] * COEFF;
    }

Normal printed values:

image
Altered printed values:

image

The line of code I'm talking about:

assert_eq!(vec_source[idx] * COEFF, vec_result[idx]);

@c0gent
Copy link
Member

c0gent commented Nov 6, 2022

Very interesting. Thanks for reporting. We'll see if anyone else experiences this.

@c0gent
Copy link
Member

c0gent commented Oct 10, 2023

I can't reproduce.

Still having this issue?

@c0gent c0gent closed this as completed Oct 10, 2023
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

No branches or pull requests

2 participants