-
-
Save Xinayder/fa444e9a8cfd8deefbde 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; | |
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