Created
December 7, 2021 11:08
-
-
Save StephanieSunshine/504560dff955dc187fb145a6bc73e7e7 to your computer and use it in GitHub Desktop.
Rust question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiling bubblerust v0.1.0 (/home/stephanie/Projects/Rust/bubblerust) | |
error[E0308]: mismatched types | |
--> src/main.rs:17:33 | |
| | |
17 | println!("{:?}", bubblesort(&list)); | |
| ^^^^^ types differ in mutability | |
| | |
= note: expected mutable reference `&mut Vec<u32>` | |
found reference `&Vec<u32>` | |
error: aborting due to previous error | |
For more information about this error, try `rustc --explain E0308`. | |
error: could not compile `bubblerust`. | |
To learn more, run the command again with --verbose. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn bubblesort(l: &mut Vec<u32>) -> &mut Vec<u32> { | |
(*l).push(100); | |
l | |
} | |
fn main() { | |
let mut list: Vec<u32> = Vec::new(); | |
list.push(20); | |
list.push(40); | |
list.push(10); | |
list.push(50); | |
list.push(5); | |
list.push(1); | |
println!("{:?}", bubblesort(&list)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment