Skip to content

Instantly share code, notes, and snippets.

@Xinayder
Forked from anonymous/playground.rs
Last active November 29, 2015 14:27
Show Gist options
  • Save Xinayder/fa444e9a8cfd8deefbde to your computer and use it in GitHub Desktop.
Save Xinayder/fa444e9a8cfd8deefbde to your computer and use it in GitHub Desktop.
Shared via Rust Playground
fn main() {
println!("{:?}", substr("abcdef", 2, 4));
}
fn substr(string: &str, start_index: u32, length: u32) -> String {
let mut result: String = String::new();
let index: usize = start_index as usize;
let mut lusize: usize = length as usize;
result.push_str(&string[index..lusize+index]);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment