Skip to content

Instantly share code, notes, and snippets.

@Thecarisma
Forked from rust-play/playground.rs
Created December 15, 2019 21:47
Show Gist options
  • Save Thecarisma/17a0b874805b0f4cebc6380305e2653d to your computer and use it in GitHub Desktop.
Save Thecarisma/17a0b874805b0f4cebc6380305e2653d to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
pub fn reverse_string(s: &mut Vec<char>) {
if s.len() <= 1 {
return;
}
let mut i = 0;
let mut j = s.len() - 1;
while i != j && i < j {
s.swap(i, j);
i += 1;
j -= 1;
}
}
fn main() {
let mut shit = vec!['H','a','n','n','a','h'];
reverse_string(&mut shit);
dbg!(shit);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment