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

warning: variable does not need to be mutable #54

Open
IvanaGyro opened this issue Mar 15, 2020 · 2 comments
Open

warning: variable does not need to be mutable #54

IvanaGyro opened this issue Mar 15, 2020 · 2 comments

Comments

@IvanaGyro
Copy link

rust-koans/src/koans/vec.rs

Lines 105 to 112 in c6e8193

// We created an empty Vec in our first example,
// now let's check if a Vec is empty
#[test]
fn empty_vecs() {
let mut vector = vec![""; 0];
assert!(vector.is_empty()); // should return true
assert!(!vector.is_empty()); // should return false
}

The case above raise a warning:

warning: variable does not need to be mutable
   --> src/koans/vec.rs:109:9
    |
109 |     let mut vector = vec![""; 0];
    |         ----^^^^^^
    |         |
    |         help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

The versions I am running:

  • cargo 1.42.0 (86334295e 2020-01-31)
  • rustc 1.42.0 (b8cedc004 2020-03-09)
@IvanaGyro
Copy link
Author

IvanaGyro commented Mar 15, 2020

What's more, that case fails the test.
Maybe it should be

 // We created an empty Vec in our first example, 
 // now let's check if a Vec is empty 
 #[test] 
 fn empty_vecs() { 
     let vector = vec![""; 0]; 
     assert!(vector.is_empty()); // should return true 
     // assert!(!vector.is_empty()); // should return false 
 } 

Thanks for this project.

@crazymykl
Copy link
Owner

The idea is that one is supposed to add code to make the vec non-empty between the two assertions. As in your other issue, a __; would make this more clear.

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