Is there a find
function in Rust's standard library which searches for a substring starting at a given index in the string? Just like indexOf
in JavaScript.
You would use str::find
on a substr and then add the offset back:
let s = "foobarfoo";
let index: Option<usize> = s[4..].find("foo").map(|i| i + 4);
println!("{:?}", index);
Some(6)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments