Created
November 29, 2015 14:24
-
-
Save anonymous/a54ad0f663543228de78 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
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 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; | |
lusize = string.len() - lusize; | |
result.push_str(&string[index..lusize]); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment