1
Fork 0
leetcode/source/implement_strstr/mod.rs

8 lines
161 B
Rust
Raw Normal View History

2022-04-06 14:20:49 +00:00
pub fn str_str(haystack: String, needle: String) -> i32 {
if needle.is_empty() {
return 0;
}
haystack.find(&needle).map(|n| n as i32).unwrap_or(-1)
}